Tweak null-checking in TextRenderer#getNextEventTime()

`subtitle` is only guaranteed to be non-null if
`nextSubtitleEventIndex != C.INDEX_UNSET`. The null check added in
0efec5f6c1
was too early.

Issue: #8017
PiperOrigin-RevId: 334777742
This commit is contained in:
ibaker 2020-10-01 11:08:36 +01:00 committed by Oliver Woodman
parent b8c8ce0ee0
commit 13d8860221
2 changed files with 8 additions and 3 deletions

View File

@ -13,6 +13,8 @@
* Add support for `\h` SSA/ASS style override code (non-breaking space).
* Fix WebVTT subtitles in MP4 containers in DASH streams
([#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:
* Do not require subtitleButton in custom layouts of StyledPlayerView
([#7962](https://github.com/google/ExoPlayer/issues/7962)).

View File

@ -325,10 +325,13 @@ public final class TextRenderer extends BaseRenderer implements Callback {
}
private long getNextEventTime() {
if (nextSubtitleEventIndex == C.INDEX_UNSET) {
return Long.MAX_VALUE;
}
checkNotNull(subtitle);
return nextSubtitleEventIndex == C.INDEX_UNSET
|| nextSubtitleEventIndex >= subtitle.getEventTimeCount()
? Long.MAX_VALUE : subtitle.getEventTime(nextSubtitleEventIndex);
return nextSubtitleEventIndex >= subtitle.getEventTimeCount()
? Long.MAX_VALUE
: subtitle.getEventTime(nextSubtitleEventIndex);
}
private void updateOutput(List<Cue> cues) {