diff --git a/RELEASENOTES.md b/RELEASENOTES.md index eb7272a701..06dc79607e 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -17,6 +17,9 @@ ([#7866](https://github.com/google/ExoPlayer/issues/7866)). * Text: * Add support for `\h` SSA/ASS style override code (non-breaking space). +* UI: + * Do not require subtitleButton in custom layouts of StyledPlayerView + ([#7962](https://github.com/google/ExoPlayer/issues/7962)). * Audio: * Retry playback after some types of `AudioTrack` error. * Extractors: diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java index 8bb9babeb0..c3add8f8af 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java @@ -2005,11 +2005,13 @@ public class StyledPlayerControlView extends FrameLayout { break; } } - checkNotNull(subtitleButton) - .setImageDrawable(subtitleIsOn ? subtitleOnButtonDrawable : subtitleOffButtonDrawable); - checkNotNull(subtitleButton) - .setContentDescription( - subtitleIsOn ? subtitleOnContentDescription : subtitleOffContentDescription); + + if (subtitleButton != null) { + subtitleButton.setImageDrawable( + subtitleIsOn ? subtitleOnButtonDrawable : subtitleOffButtonDrawable); + subtitleButton.setContentDescription( + subtitleIsOn ? subtitleOnContentDescription : subtitleOffContentDescription); + } this.rendererIndices = rendererIndices; this.tracks = trackInfos; this.mappedTrackInfo = mappedTrackInfo;