diff --git a/src/controller/subtitle-stream-controller.ts b/src/controller/subtitle-stream-controller.ts index 3f9e5aba00c..5e73b46b0cf 100644 --- a/src/controller/subtitle-stream-controller.ts +++ b/src/controller/subtitle-stream-controller.ts @@ -288,16 +288,20 @@ export class SubtitleStreamController fragPrevious.endProgramDateTime, maxFragLookUpTolerance ); - if (!foundFrag) { - foundFrag = findFragmentByPTS( - fragPrevious, - fragments, - targetBufferTime, - maxFragLookUpTolerance - ); - if (!foundFrag && fragPrevious.start < fragments[0].start) { - foundFrag = fragments[0]; - } + } + if (!foundFrag) { + foundFrag = findFragmentByPTS( + fragPrevious, + fragments, + targetBufferTime, + maxFragLookUpTolerance + ); + if ( + !foundFrag && + fragPrevious && + fragPrevious.start < fragments[0].start + ) { + foundFrag = fragments[0]; } } } else {