Skip to content

Commit

Permalink
check tunneling directly on TrackSelector parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin committed Jan 4, 2023
1 parent fcfacda commit e1dd2b2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.schabi.newpipe.player;

import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW;
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_FAILED_RUNTIME_CHECK;
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS;
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED;
import static com.google.android.exoplayer2.PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND;
Expand Down Expand Up @@ -66,7 +67,6 @@

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;
Expand Down Expand Up @@ -1430,21 +1430,22 @@ public void onPlayerError(@NonNull final PlaybackException error) {
setRecovery();
reloadPlayQueueManager();
break;
default:
case ERROR_CODE_FAILED_RUNTIME_CHECK:
// 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")) {
Log.d(TAG, "Unexpected PlaybackException! Cause: "
+ Log.getStackTraceString(error.getCause()));
if (trackSelector.getParameters().tunnelingEnabled
&& Log.getStackTraceString(error.getCause())
.contains("Surface")) {
trackSelector.setParameters(trackSelector.buildUponParameters()
.setTunnelingEnabled(false));
// Reload playback on unexpected errors:
setRecovery();
reloadPlayQueueManager();
break;
}
// fall through to default
default:
// API, remote and renderer errors belong here:
onPlaybackShutdown();
break;
Expand Down

0 comments on commit e1dd2b2

Please sign in to comment.