Skip to content

Commit

Permalink
fix: Fix choppy HLS startup (shaka-project#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 shaka-project#4516
  • Loading branch information
nyanmisaka committed Oct 6, 2022
1 parent 593c280 commit 59ef54a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/media/media_source_engine.js
Expand Up @@ -674,10 +674,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 59ef54a

Please sign in to comment.