From e44da8fcc032c4d24b30d926fa23c33111da0975 Mon Sep 17 00:00:00 2001 From: Will Harris Date: Fri, 23 Aug 2024 12:14:39 -0400 Subject: [PATCH] fix: Add null check for current reference (#7184) Resolves https://github.com/shaka-project/shaka-player/issues/7174. --- lib/media/streaming_engine.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index d08b58a174..4acda2bef5 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -1511,11 +1511,14 @@ shaka.media.StreamingEngine = class { mediaState.stream.segmentIndex, 'segment index should have been generated already'); - if (mediaState.segmentIterator) { + const currentSegment = mediaState.segmentIterator ? + mediaState.segmentIterator.current() : null; + + if (currentSegment) { // Something is buffered from the same Stream. Use the current position // in the segment index. This is updated via next() after each segment is // appended. - return mediaState.segmentIterator.current(); + return currentSegment; } else if (mediaState.lastSegmentReference || bufferEnd) { // Something is buffered from another Stream. const time = mediaState.lastSegmentReference ?