From 543f60927d9ae25fc9aac719cd39e94828c30037 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 3 Jan 2023 14:26:32 +0100 Subject: [PATCH] Disable tunneling on internal Surface related Exceptions --- .../java/org/schabi/newpipe/player/Player.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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;