diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java index a2ba72dbc0..4cecf7ce3c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java @@ -1455,6 +1455,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer { protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException { waitingForFirstSampleInFormat = true; Format newFormat = Assertions.checkNotNull(formatHolder.format); + if (newFormat.sampleMimeType == null) { + // If the new format is invalid, it is either a media bug or it is not intended to be played. + // See also https://github.com/google/ExoPlayer/issues/8283. + throw createRendererException(new IllegalArgumentException(), newFormat); + } setSourceDrmSession(formatHolder.drmSession); inputFormat = newFormat;