Commit 907e2e05 by ibaker Committed by kim-vde

Tweak null-checking in TextRenderer#getNextEventTime()

`subtitle` is only guaranteed to be non-null if
`nextSubtitleEventIndex != C.INDEX_UNSET`. The null check added in
https://github.com/google/ExoPlayer/commit/0efec5f6c12a5d583f24c122fbcbc1b1eebbabc3
was too early.

Issue: #8017
PiperOrigin-RevId: 334777742
parent 990051f5
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
* Add support for `\h` SSA/ASS style override code (non-breaking space). * Add support for `\h` SSA/ASS style override code (non-breaking space).
* Fix WebVTT subtitles in MP4 containers in DASH streams * Fix WebVTT subtitles in MP4 containers in DASH streams
([#7985](https://github.com/google/ExoPlayer/issues/7985)). ([#7985](https://github.com/google/ExoPlayer/issues/7985)).
* Fix NPE in `TextRenderer` when playing content with a single subtitle
buffer ([#8017](https://github.com/google/ExoPlayer/issues/8017)).
* UI: * UI:
* Do not require subtitleButton in custom layouts of StyledPlayerView * Do not require subtitleButton in custom layouts of StyledPlayerView
([#7962](https://github.com/google/ExoPlayer/issues/7962)). ([#7962](https://github.com/google/ExoPlayer/issues/7962)).
......
...@@ -325,10 +325,13 @@ public final class TextRenderer extends BaseRenderer implements Callback { ...@@ -325,10 +325,13 @@ public final class TextRenderer extends BaseRenderer implements Callback {
} }
private long getNextEventTime() { private long getNextEventTime() {
if (nextSubtitleEventIndex == C.INDEX_UNSET) {
return Long.MAX_VALUE;
}
checkNotNull(subtitle); checkNotNull(subtitle);
return nextSubtitleEventIndex == C.INDEX_UNSET return nextSubtitleEventIndex >= subtitle.getEventTimeCount()
|| nextSubtitleEventIndex >= subtitle.getEventTimeCount() ? Long.MAX_VALUE
? Long.MAX_VALUE : subtitle.getEventTime(nextSubtitleEventIndex); : subtitle.getEventTime(nextSubtitleEventIndex);
} }
private void updateOutput(List<Cue> cues) { private void updateOutput(List<Cue> cues) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment