1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 11:02:35 +01:00

updated: source loading error for FailedMediaSource to wait for 3 seconds before allowing retry.

updated: minor style fixes.
This commit is contained in:
karyogamy 2022-03-27 13:24:37 -04:00
parent d289dc8a53
commit a00bc95acc
3 changed files with 10 additions and 5 deletions

View File

@ -2487,11 +2487,11 @@ public final class Player implements
/**
* <p>Listens for event or state changes on ExoPlayer. When any event happens, we check for
* changes in the currently-playing metadata and update the encapsulating
* {@link Player}. Downstream listeners are also informed.
* {@link Player}. Downstream listeners are also informed.</p>
*
* <p>When the renewed metadata contains any error, it is reported as a notification.
* This is done because not all source resolution errors are {@link PlaybackException}, which
* are also captured by {@link ExoPlayer} and stops the playback.
* are also captured by {@link ExoPlayer} and stops the playback.</p>
*
* @param player The {@link com.google.android.exoplayer2.Player} whose state changed.
* @param events The {@link com.google.android.exoplayer2.Player.Events} that has triggered
@ -2634,6 +2634,9 @@ public final class Player implements
* </ul>
* @see com.google.android.exoplayer2.Player.Listener#onPlayerError(PlaybackException)
* */
// Any error code not explicitly covered here are either unrelated to NewPipe use case
// (e.g. DRM) or not recoverable (e.g. Decoder error). In both cases, the player should
// shutdown.
@SuppressLint("SwitchIntDef")
@Override
public void onPlayerError(@NonNull final PlaybackException error) {

View File

@ -78,7 +78,7 @@ public class FailedMediaSource extends BaseMediaSource implements ManagedMediaSo
return playQueueItem;
}
public Throwable getError() {
public Exception getError() {
return error;
}

View File

@ -441,8 +441,10 @@ public class MediaSourceManager {
if (throwable instanceof ExtractionException) {
return FailedMediaSource.of(stream, new StreamInfoLoadException(throwable));
}
return FailedMediaSource
.of(stream, new Exception(throwable), /*immediatelyRetryable=*/0L);
// Non-source related error expected here (e.g. network),
// should allow retry shortly after the error.
return FailedMediaSource.of(stream, new Exception(throwable),
/*allowRetryIn=*/TimeUnit.MILLISECONDS.convert(3, TimeUnit.SECONDS));
});
}