1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 00:20:32 +00: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 * <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 * 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. * <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 * 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 player The {@link com.google.android.exoplayer2.Player} whose state changed.
* @param events The {@link com.google.android.exoplayer2.Player.Events} that has triggered * @param events The {@link com.google.android.exoplayer2.Player.Events} that has triggered
@ -2634,6 +2634,9 @@ public final class Player implements
* </ul> * </ul>
* @see com.google.android.exoplayer2.Player.Listener#onPlayerError(PlaybackException) * @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") @SuppressLint("SwitchIntDef")
@Override @Override
public void onPlayerError(@NonNull final PlaybackException error) { public void onPlayerError(@NonNull final PlaybackException error) {

View File

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

View File

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