diff --git a/packages/video_player/video_player/lib/video_player.dart b/packages/video_player/video_player/lib/video_player.dart index 8fd216286fca..1d3915283b46 100644 --- a/packages/video_player/video_player/lib/video_player.dart +++ b/packages/video_player/video_player/lib/video_player.dart @@ -366,7 +366,9 @@ class VideoPlayerController extends ValueNotifier { isInitialized: event.duration != null, errorDescription: null, ); - initializingCompleter.complete(null); + if (!initializingCompleter.isCompleted) { + initializingCompleter.complete(null); + } _applyLooping(); _applyVolume(); _applyPlayPause(); @@ -401,7 +403,7 @@ class VideoPlayerController extends ValueNotifier { void errorListener(Object obj) { final PlatformException e = obj as PlatformException; - value = VideoPlayerValue.erroneous(e.message!); + value = value.copyWith(errorDescription: e.message!); _timer?.cancel(); if (!initializingCompleter.isCompleted) { initializingCompleter.completeError(obj); @@ -816,7 +818,7 @@ class _VideoScrubberState extends State<_VideoScrubber> { } _controllerWasPlaying = controller.value.isPlaying; if (_controllerWasPlaying) { - controller.pause(); + //controller.pause(); } }, onHorizontalDragUpdate: (DragUpdateDetails details) { @@ -828,7 +830,7 @@ class _VideoScrubberState extends State<_VideoScrubber> { onHorizontalDragEnd: (DragEndDetails details) { if (_controllerWasPlaying && controller.value.position != controller.value.duration) { - controller.play(); + //controller.play(); } }, onTapDown: (TapDownDetails details) { @@ -1040,4 +1042,4 @@ class ClosedCaption extends StatelessWidget { /// We use this so that APIs that have become non-nullable can still be used /// with `!` and `?` on the stable branch. // TODO(ianh): Remove this once we roll stable in late 2021. -T? _ambiguate(T? value) => value; +T? _ambiguate(T? value) => value; \ No newline at end of file diff --git a/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java b/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java index 887d3d15f175..c343d9860195 100644 --- a/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java +++ b/packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java @@ -190,26 +190,21 @@ public void onPlaybackStateChanged(final int playbackState) { setBuffering(true); sendBufferingUpdate(); } else if (playbackState == Player.STATE_READY) { - if (!isInitialized) { - isInitialized = true; - sendInitialized(); - } + setBuffering(false); + isInitialized = true; + sendInitialized(); } else if (playbackState == Player.STATE_ENDED) { Map event = new HashMap<>(); event.put("event", "completed"); eventSink.success(event); } - - if (playbackState != Player.STATE_BUFFERING) { - setBuffering(false); - } } @Override public void onPlayerError(final ExoPlaybackException error) { - setBuffering(false); if (eventSink != null) { eventSink.error("VideoError", "Video player had error " + error, null); + exoPlayer.prepare(); } } }); @@ -300,4 +295,4 @@ void dispose() { exoPlayer.release(); } } -} +} \ No newline at end of file