diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 99d36f66eea..3883f3e9f12 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -66,6 +66,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.DefaultRenderersFactory; +import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.PlaybackException; import com.google.android.exoplayer2.PlaybackParameters; @@ -1430,6 +1431,20 @@ public void onPlayerError(@NonNull final PlaybackException error) { reloadPlayQueueManager(); break; default: + // Try to handle tunneling related exceptions + final ExoPlaybackException epe = !exoPlayerIsNull() + ? simpleExoPlayer.getPlayerError() : null; + if (epe != null && epe.type == ExoPlaybackException.TYPE_UNEXPECTED + && simpleExoPlayer.isTunnelingEnabled() + && Log.getStackTraceString(epe.getUnexpectedException()) + .contains("Surface")) { + trackSelector.setParameters(trackSelector.buildUponParameters() + .setTunnelingEnabled(false)); + // Reload playback on unexpected errors: + setRecovery(); + reloadPlayQueueManager(); + break; + } // API, remote and renderer errors belong here: onPlaybackShutdown(); break;