mirror of
https://github.com/samsonjs/media.git
synced 2026-04-02 10:45:51 +00:00
Fix TextRenderer exception when a subtitle file contains no cues
Discovered while investigating Issue: google/ExoPlayer#10823
Example stack trace with the previous code (I added the index value for
debugging):
```
playerFailed [eventTime=44.07, mediaPos=44.01, window=0, period=0, errorCode=ERROR_CODE_FAILED_RUNTIME_CHECK
androidx.media3.exoplayer.ExoPlaybackException: Unexpected runtime error
at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:635)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:202)
at android.os.Looper.loop(Looper.java:291)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.IllegalArgumentException: index=-1
at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:55)
at androidx.media3.extractor.text.webvtt.WebvttSubtitle.getEventTime(WebvttSubtitle.java:62)
at androidx.media3.extractor.text.SubtitleOutputBuffer.getEventTime(SubtitleOutputBuffer.java:56)
at androidx.media3.exoplayer.text.TextRenderer.getCurrentEventTimeUs(TextRenderer.java:435)
at androidx.media3.exoplayer.text.TextRenderer.render(TextRenderer.java:268)
at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1008)
at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:509)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:202)
at android.os.Looper.loop(Looper.java:291)
at android.os.HandlerThread.run(HandlerThread.java:67)
]
```
#minor-release
PiperOrigin-RevId: 492464180
(cherry picked from commit 33bbb9511a)
This commit is contained in:
parent
8844b4f646
commit
5612f6924a
2 changed files with 3 additions and 1 deletions
|
|
@ -17,6 +17,8 @@
|
|||
* Use the compressed audio format bitrate to calculate the min buffer size
|
||||
for `AudioTrack` in direct playbacks (passthrough).
|
||||
* Text:
|
||||
* Fix `TextRenderer` passing an invalid (negative) index to
|
||||
`Subtitle.getEventTime` if a subtitle file contains no cues.
|
||||
* SubRip: Add support for UTF-16 files if they start with a byte order
|
||||
mark.
|
||||
* Session:
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ public final class TextRenderer extends BaseRenderer implements Callback {
|
|||
@SideEffectFree
|
||||
private long getCurrentEventTimeUs(long positionUs) {
|
||||
int nextEventTimeIndex = subtitle.getNextEventTimeIndex(positionUs);
|
||||
if (nextEventTimeIndex == 0) {
|
||||
if (nextEventTimeIndex == 0 || subtitle.getEventTimeCount() == 0) {
|
||||
return subtitle.timeUs;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue