@@ -2517,23 +2517,11 @@ public void onPlayerError(@NonNull final ExoPlaybackException error) {
25172517 Log .e (TAG , "ExoPlayer - onPlayerError() called with:" , error );
25182518
25192519 saveStreamProgressState ();
2520-
2521- // create error notification
2522- final ErrorInfo errorInfo ;
2523- if (currentMetadata == null ) {
2524- errorInfo = new ErrorInfo (error , UserAction .PLAY_STREAM ,
2525- "Player error[type=" + error .type + "] occurred, currentMetadata is null" );
2526- } else {
2527- errorInfo = new ErrorInfo (error , UserAction .PLAY_STREAM ,
2528- "Player error[type=" + error .type + "] occurred while playing "
2529- + currentMetadata .getMetadata ().getUrl (),
2530- currentMetadata .getMetadata ());
2531- }
2532- ErrorUtil .createNotification (context , errorInfo );
2520+ boolean isCatchableException = false ;
25332521
25342522 switch (error .type ) {
25352523 case ExoPlaybackException .TYPE_SOURCE :
2536- processSourceError (error .getSourceException ());
2524+ isCatchableException = processSourceError (error .getSourceException ());
25372525 break ;
25382526 case ExoPlaybackException .TYPE_UNEXPECTED :
25392527 setRecovery ();
@@ -2546,22 +2534,60 @@ public void onPlayerError(@NonNull final ExoPlaybackException error) {
25462534 break ;
25472535 }
25482536
2537+ if (isCatchableException ) {
2538+ return ;
2539+ }
2540+
2541+ createErrorNotification (error );
2542+
25492543 if (fragmentListener != null ) {
25502544 fragmentListener .onPlayerError (error );
25512545 }
25522546 }
25532547
2554- private void processSourceError (final IOException error ) {
2548+ private void createErrorNotification (@ NonNull final ExoPlaybackException error ) {
2549+ final ErrorInfo errorInfo ;
2550+ if (currentMetadata == null ) {
2551+ errorInfo = new ErrorInfo (error , UserAction .PLAY_STREAM ,
2552+ "Player error[type=" + error .type + "] occurred, currentMetadata is null" );
2553+ } else {
2554+ errorInfo = new ErrorInfo (error , UserAction .PLAY_STREAM ,
2555+ "Player error[type=" + error .type + "] occurred while playing "
2556+ + currentMetadata .getMetadata ().getUrl (),
2557+ currentMetadata .getMetadata ());
2558+ }
2559+ ErrorUtil .createNotification (context , errorInfo );
2560+ }
2561+
2562+ /**
2563+ * Process an {@link IOException} returned by {@link ExoPlaybackException#getSourceException()}
2564+ * for {@link ExoPlaybackException#TYPE_SOURCE} exceptions.
2565+ *
2566+ * <p>
2567+ * This method sets the recovery position and sends an error message to the play queue if the
2568+ * exception is not a {@link BehindLiveWindowException}.
2569+ * </p>
2570+ * @param error the source error which was thrown by ExoPlayer
2571+ * @return whether the exception thrown is a {@link BehindLiveWindowException} ({@code false}
2572+ * is always returned if ExoPlayer or the play queue is null)
2573+ */
2574+ private boolean processSourceError (final IOException error ) {
25552575 if (exoPlayerIsNull () || playQueue == null ) {
2556- return ;
2576+ return false ;
25572577 }
2578+
25582579 setRecovery ();
25592580
25602581 if (error instanceof BehindLiveWindowException ) {
2561- reloadPlayQueueManager ();
2562- } else {
2563- playQueue .error ();
2582+ simpleExoPlayer .seekToDefaultPosition ();
2583+ simpleExoPlayer .prepare ();
2584+ // Inform the user that we are reloading the stream by switching to the buffering state
2585+ onBuffering ();
2586+ return true ;
25642587 }
2588+
2589+ playQueue .error ();
2590+ return false ;
25652591 }
25662592 //endregion
25672593
0 commit comments