Skip to content

Commit

Permalink
fix: Fix choppy HLS startup (#4553)
Browse files Browse the repository at this point in the history
Clearing the buffer seems to be not enough for this case.
This avoids the choppy video start on HLS fMP4 playback.

Tested with Chrome 106 & Edge 106.

Closes #4516
  • Loading branch information
nyanmisaka authored and joeyparrish committed Oct 7, 2022
1 parent 8204db6 commit 950ce69
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,17 @@ shaka.media.MediaSourceEngine = class {
const textOffset = (reference.startTime || 0) - (mediaStartTime || 0);
this.textSequenceModeOffset_.resolve(textOffset);

// Finally, clear the buffer.
// Clear the buffer.
await this.enqueueOperation_(
contentType,
() => this.remove_(contentType, 0, this.mediaSource_.duration));

// Finally, flush the buffer in case of choppy video start on HLS fMP4.
if (contentType == ContentType.VIDEO) {
await this.enqueueOperation_(
contentType,
() => this.flush_(contentType));
}
}

// Now switch to sequence mode and fall through to our normal operations.
Expand Down

0 comments on commit 950ce69

Please sign in to comment.