Skip to content

Commit

Permalink
Disable direct play when encountering playback error twice
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Aug 20, 2024
1 parent a9ff992 commit 1199fa5
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public class PlaybackController implements PlaybackControllerNotifiable {
private long mCurrentTranscodeStartTime;
private boolean isLiveTv = false;
private boolean directStreamLiveTv;
private boolean exoErrorEncountered;
private int playbackRetries = 0;
private long lastPlaybackError = 0;

Expand Down Expand Up @@ -247,8 +246,6 @@ public boolean isPlaying() {
}

public void playerErrorEncountered() {
exoErrorEncountered = true;

// reset the retry count if it's been more than 30s since previous error
if (playbackRetries > 0 && Instant.now().toEpochMilli() - lastPlaybackError > 30000) {
Timber.d("playback stabilized - retry count reset to 0 from %s", playbackRetries);
Expand Down Expand Up @@ -516,8 +513,8 @@ private VideoOptions buildExoPlayerOptions(@Nullable Integer forcedSubtitleIndex
internalOptions.setItemId(item.getId());
internalOptions.setMediaSources(item.getMediaSources());
internalOptions.setMaxBitrate(maxBitrate);
if (exoErrorEncountered || (isLiveTv && !directStreamLiveTv))
internalOptions.setEnableDirectStream(false);
if (playbackRetries > 0 || (isLiveTv && !directStreamLiveTv)) internalOptions.setEnableDirectStream(false);
if (playbackRetries > 1) internalOptions.setEnableDirectPlay(false);
internalOptions.setSubtitleStreamIndex(forcedSubtitleIndex);
MediaSourceInfo currentMediaSource = getCurrentMediaSource();
if (!isLiveTv && currentMediaSource != null) {
Expand Down Expand Up @@ -876,7 +873,7 @@ public void endPlayback() {
}

private void resetPlayerErrors() {
exoErrorEncountered = false;
playbackRetries = 0;
}

private void clearPlaybackSessionOptions() {
Expand Down

0 comments on commit 1199fa5

Please sign in to comment.