Skip to content

Commit a00bc95

Browse files
committed
updated: source loading error for FailedMediaSource to wait for 3 seconds before allowing retry.
updated: minor style fixes.
1 parent d289dc8 commit a00bc95

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,11 +2487,11 @@ private void setMuteButton(@NonNull final ImageButton button, final boolean isMu
24872487
/**
24882488
* <p>Listens for event or state changes on ExoPlayer. When any event happens, we check for
24892489
* changes in the currently-playing metadata and update the encapsulating
2490-
* {@link Player}. Downstream listeners are also informed.
2490+
* {@link Player}. Downstream listeners are also informed.</p>
24912491
*
24922492
* <p>When the renewed metadata contains any error, it is reported as a notification.
24932493
* This is done because not all source resolution errors are {@link PlaybackException}, which
2494-
* are also captured by {@link ExoPlayer} and stops the playback.
2494+
* are also captured by {@link ExoPlayer} and stops the playback.</p>
24952495
*
24962496
* @param player The {@link com.google.android.exoplayer2.Player} whose state changed.
24972497
* @param events The {@link com.google.android.exoplayer2.Player.Events} that has triggered
@@ -2634,6 +2634,9 @@ public void onCues(@NonNull final List<Cue> cues) {
26342634
* </ul>
26352635
* @see com.google.android.exoplayer2.Player.Listener#onPlayerError(PlaybackException)
26362636
* */
2637+
// Any error code not explicitly covered here are either unrelated to NewPipe use case
2638+
// (e.g. DRM) or not recoverable (e.g. Decoder error). In both cases, the player should
2639+
// shutdown.
26372640
@SuppressLint("SwitchIntDef")
26382641
@Override
26392642
public void onPlayerError(@NonNull final PlaybackException error) {

app/src/main/java/org/schabi/newpipe/player/mediasource/FailedMediaSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public PlayQueueItem getStream() {
7878
return playQueueItem;
7979
}
8080

81-
public Throwable getError() {
81+
public Exception getError() {
8282
return error;
8383
}
8484

app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,10 @@ private Single<ManagedMediaSource> getLoadedMediaSource(@NonNull final PlayQueue
441441
if (throwable instanceof ExtractionException) {
442442
return FailedMediaSource.of(stream, new StreamInfoLoadException(throwable));
443443
}
444-
return FailedMediaSource
445-
.of(stream, new Exception(throwable), /*immediatelyRetryable=*/0L);
444+
// Non-source related error expected here (e.g. network),
445+
// should allow retry shortly after the error.
446+
return FailedMediaSource.of(stream, new Exception(throwable),
447+
/*allowRetryIn=*/TimeUnit.MILLISECONDS.convert(3, TimeUnit.SECONDS));
446448
});
447449
}
448450

0 commit comments

Comments
 (0)