@@ -14,10 +14,10 @@ import 'package:video_player_platform_interface/video_player_platform_interface.
1414export 'package:video_player_platform_interface/video_player_platform_interface.dart'
1515 show DurationRange, DataSourceType, VideoFormat;
1616
17- // This will clear all open videos on the platform when a full restart is
18- // performed.
19- // ignore: unused_element
20- final VideoPlayerPlatform _ = VideoPlayerPlatform .instance ..init ();
17+ final VideoPlayerPlatform _videoPlayerPlatform = VideoPlayerPlatform .instance
18+ // This will clear all open videos on the platform when a full restart is
19+ // performed.
20+ ..init ();
2121
2222/// The duration, current position, buffering state, error state and settings
2323/// of a [VideoPlayerController] .
@@ -229,8 +229,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
229229 );
230230 break ;
231231 }
232- _textureId =
233- await VideoPlayerPlatform .instance.create (dataSourceDescription);
232+ _textureId = await _videoPlayerPlatform.create (dataSourceDescription);
234233 _creatingCompleter.complete (null );
235234 final Completer <void > initializingCompleter = Completer <void >();
236235
@@ -277,7 +276,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
277276 }
278277 }
279278
280- _eventSubscription = VideoPlayerPlatform .instance
279+ _eventSubscription = _videoPlayerPlatform
281280 .videoEventsFor (_textureId)
282281 .listen (eventListener, onError: errorListener);
283282 return initializingCompleter.future;
@@ -291,7 +290,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
291290 _isDisposed = true ;
292291 _timer? .cancel ();
293292 await _eventSubscription? .cancel ();
294- await VideoPlayerPlatform .instance .dispose (_textureId);
293+ await _videoPlayerPlatform .dispose (_textureId);
295294 }
296295 _lifeCycleObserver.dispose ();
297296 }
@@ -326,15 +325,15 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
326325 if (! value.initialized || _isDisposed) {
327326 return ;
328327 }
329- await VideoPlayerPlatform .instance .setLooping (_textureId, value.isLooping);
328+ await _videoPlayerPlatform .setLooping (_textureId, value.isLooping);
330329 }
331330
332331 Future <void > _applyPlayPause () async {
333332 if (! value.initialized || _isDisposed) {
334333 return ;
335334 }
336335 if (value.isPlaying) {
337- await VideoPlayerPlatform .instance .play (_textureId);
336+ await _videoPlayerPlatform .play (_textureId);
338337 _timer = Timer .periodic (
339338 const Duration (milliseconds: 500 ),
340339 (Timer timer) async {
@@ -350,23 +349,23 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
350349 );
351350 } else {
352351 _timer? .cancel ();
353- await VideoPlayerPlatform .instance .pause (_textureId);
352+ await _videoPlayerPlatform .pause (_textureId);
354353 }
355354 }
356355
357356 Future <void > _applyVolume () async {
358357 if (! value.initialized || _isDisposed) {
359358 return ;
360359 }
361- await VideoPlayerPlatform .instance .setVolume (_textureId, value.volume);
360+ await _videoPlayerPlatform .setVolume (_textureId, value.volume);
362361 }
363362
364363 /// The position in the current video.
365364 Future <Duration > get position async {
366365 if (_isDisposed) {
367366 return null ;
368367 }
369- return await VideoPlayerPlatform .instance .getPosition (_textureId);
368+ return await _videoPlayerPlatform .getPosition (_textureId);
370369 }
371370
372371 /// Sets the video's current timestamp to be at [moment] . The next
@@ -383,7 +382,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
383382 } else if (position < const Duration ()) {
384383 position = const Duration ();
385384 }
386- await VideoPlayerPlatform .instance .seekTo (_textureId, position);
385+ await _videoPlayerPlatform .seekTo (_textureId, position);
387386 value = value.copyWith (position: position);
388387 }
389388
@@ -483,7 +482,7 @@ class _VideoPlayerState extends State<VideoPlayer> {
483482 Widget build (BuildContext context) {
484483 return _textureId == null
485484 ? Container ()
486- : VideoPlayerPlatform .instance .buildView (_textureId);
485+ : _videoPlayerPlatform .buildView (_textureId);
487486 }
488487}
489488
0 commit comments