-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[video_player_android] Handle BehindLiveWindowException #5869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
df58d1b
128ef9d
da6280e
2cc8ab1
c5f4b4f
af94aa0
6ca509c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,7 +227,11 @@ public void onPlaybackStateChanged(final int playbackState) { | |
| @Override | ||
| public void onPlayerError(@NonNull final PlaybackException error) { | ||
| setBuffering(false); | ||
| if (eventSink != null) { | ||
| if (error.errorCode == PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW) { | ||
| // See https://exoplayer.dev/live-streaming.html#behindlivewindowexception-and-error_code_behind_live_window | ||
| exoPlayer.seekToDefaultPosition(); | ||
| exoPlayer.prepare(); | ||
| } else if (eventSink != null) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would we not still want to forward the video error to Dart?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think not, since it's basically un-actionable from Dart. It could make sense if there was an option to disable this error handling logic from Dart, but it would require a change in platform interface - this seems to be an overkill for this fix.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Longer term it would make more sense to have no handling here, and forward more structured errors to the clients so they could decide how to handle them, but we can start with this and see if there are requests for more control. |
||
| eventSink.error("VideoError", "Video player had error " + error, null); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,22 +5,25 @@ | |||||
| package io.flutter.plugins.videoplayer; | ||||||
|
|
||||||
| import static org.junit.Assert.assertEquals; | ||||||
| import static org.mockito.ArgumentMatchers.any; | ||||||
| import static org.mockito.ArgumentMatchers.anyBoolean; | ||||||
| import static org.mockito.Mockito.*; | ||||||
| import static org.mockito.Mockito.any; | ||||||
| import static org.mockito.Mockito.doAnswer; | ||||||
| import static org.mockito.Mockito.mock; | ||||||
| import static org.mockito.Mockito.never; | ||||||
| import static org.mockito.Mockito.spy; | ||||||
| import static org.mockito.Mockito.times; | ||||||
| import static org.mockito.Mockito.verify; | ||||||
| import static org.mockito.Mockito.when; | ||||||
|
|
||||||
| import com.google.android.exoplayer2.ExoPlayer; | ||||||
| import com.google.android.exoplayer2.Format; | ||||||
| import com.google.android.exoplayer2.PlaybackException; | ||||||
| import com.google.android.exoplayer2.Player; | ||||||
| import com.google.android.exoplayer2.upstream.DefaultHttpDataSource; | ||||||
| import io.flutter.plugin.common.EventChannel; | ||||||
| import io.flutter.view.TextureRegistry; | ||||||
| import java.util.HashMap; | ||||||
| import java.util.LinkedList; | ||||||
| import java.util.List; | ||||||
| import java.util.Map; | ||||||
| import org.junit.Before; | ||||||
| import org.junit.Test; | ||||||
|
|
@@ -278,4 +281,28 @@ public void onIsPlayingChangedSendsExpectedEvent() { | |||||
| assertEquals(event2.get("event"), "isPlayingStateUpdate"); | ||||||
| assertEquals(event2.get("isPlaying"), false); | ||||||
| } | ||||||
|
|
||||||
| @Test | ||||||
| public void behindLiveWindowErrorResets() { | ||||||
|
||||||
| public void behindLiveWindowErrorResets() { | |
| public void behindLiveWindowErrorResetsPlaybackPositionToDefault() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: