diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java index 12afa0544d..6e1b9a706b 100644 --- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java +++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java @@ -456,35 +456,33 @@ public class PlayerActivity extends AppCompatActivity } } - private class PlayerErrorMessageProvider implements ErrorMessageProvider { + private class PlayerErrorMessageProvider implements ErrorMessageProvider { @Override @NonNull - public Pair getErrorMessage(@NonNull ExoPlaybackException e) { + public Pair getErrorMessage(@NonNull PlaybackException e) { String errorString = getString(R.string.error_generic); - if (e.type == ExoPlaybackException.TYPE_RENDERER) { - Exception cause = e.getRendererException(); - if (cause instanceof DecoderInitializationException) { - // Special case for decoder initialization failures. - DecoderInitializationException decoderInitializationException = - (DecoderInitializationException) cause; - if (decoderInitializationException.codecInfo == null) { - if (decoderInitializationException.getCause() instanceof DecoderQueryException) { - errorString = getString(R.string.error_querying_decoders); - } else if (decoderInitializationException.secureDecoderRequired) { - errorString = - getString( - R.string.error_no_secure_decoder, decoderInitializationException.mimeType); - } else { - errorString = - getString(R.string.error_no_decoder, decoderInitializationException.mimeType); - } - } else { + Throwable cause = e.getCause(); + if (cause instanceof DecoderInitializationException) { + // Special case for decoder initialization failures. + DecoderInitializationException decoderInitializationException = + (DecoderInitializationException) cause; + if (decoderInitializationException.codecInfo == null) { + if (decoderInitializationException.getCause() instanceof DecoderQueryException) { + errorString = getString(R.string.error_querying_decoders); + } else if (decoderInitializationException.secureDecoderRequired) { errorString = getString( - R.string.error_instantiating_decoder, - decoderInitializationException.codecInfo.name); + R.string.error_no_secure_decoder, decoderInitializationException.mimeType); + } else { + errorString = + getString(R.string.error_no_decoder, decoderInitializationException.mimeType); } + } else { + errorString = + getString( + R.string.error_instantiating_decoder, + decoderInitializationException.codecInfo.name); } } return Pair.create(0, errorString); diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java index 33dc593e05..eab989bd22 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java @@ -48,8 +48,8 @@ import androidx.annotation.RequiresApi; import androidx.core.content.ContextCompat; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ControlDispatcher; -import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.Format; +import com.google.android.exoplayer2.PlaybackException; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player.DiscontinuityReason; import com.google.android.exoplayer2.Timeline; @@ -306,7 +306,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { @Nullable private Drawable defaultArtwork; private @ShowBuffering int showBuffering; private boolean keepContentOnPlayerReset; - @Nullable private ErrorMessageProvider errorMessageProvider; + @Nullable private ErrorMessageProvider errorMessageProvider; @Nullable private CharSequence customErrorMessage; private int controllerShowTimeoutMs; private boolean controllerAutoShow; @@ -760,7 +760,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { * @param errorMessageProvider The error message provider. */ public void setErrorMessageProvider( - @Nullable ErrorMessageProvider errorMessageProvider) { + @Nullable ErrorMessageProvider errorMessageProvider) { if (this.errorMessageProvider != errorMessageProvider) { this.errorMessageProvider = errorMessageProvider; updateErrorMessage(); @@ -1414,7 +1414,7 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { errorMessageView.setVisibility(View.VISIBLE); return; } - @Nullable ExoPlaybackException error = player != null ? player.getPlayerError() : null; + @Nullable PlaybackException error = player != null ? player.getPlayerError() : null; if (error != null && errorMessageProvider != null) { CharSequence errorMessage = errorMessageProvider.getErrorMessage(error).second; errorMessageView.setText(errorMessage);