Skip to content

Commit

Permalink
fix(HLS): Avoid HLS resync when there is a gap in the stream (#5284)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored and JulianDomingo committed Jun 20, 2023
1 parent b549b60 commit 256cf20
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,15 @@ shaka.media.StreamingEngine = class {
const mediaState = this.mediaStates_.get(type);
const logPrefix = shaka.media.StreamingEngine.logPrefix_(mediaState);

// Always clear the iterator since we need to start streaming from the
// new time. This also happens in clearBuffer_, but if we don't clear,
// we still want to reset the iterator.
mediaState.segmentIterator = null;
let segment = null;
if (mediaState.segmentIterator) {
segment = mediaState.segmentIterator.current();
}
// Only reset the iterator if we seek outside the current segment.
if (!segment || segment.startTime > presentationTime ||
segment.endTime < presentationTime) {
mediaState.segmentIterator = null;
}

if (!newTimeIsBuffered(type)) {
const bufferEnd =
Expand Down

0 comments on commit 256cf20

Please sign in to comment.