Skip to content

Commit

Permalink
fix(HLS): don't do sequence mode workaround unless there's a text str…
Browse files Browse the repository at this point in the history
…eam (#5079)

The VTT cue timing fix in
#4217 seems to have
caused a regression for videos without VTT streams, where the first
segment would sometimes not play smoothly. It also appears to fix the
gap jumping seen in the "Art of Motion (HLS, TS)" demo. This was
partially fixed for fMP4 in
#4553 but didn't fix
the issue for MPEG-2 TS.

Fixes #4975.
  • Loading branch information
swac committed Mar 16, 2023
1 parent 42a9f96 commit fb22669
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/media/media_source_engine.js
Expand Up @@ -408,6 +408,13 @@ shaka.media.MediaSourceEngine = class {
'expected \'open\'');
}

if (sequenceMode && !streamsByType.has(ContentType.TEXT)) {
// There's no text stream, so we can set sequence mode early instead
// of setting it after the first segment is appended in appendBuffer_.
sourceBuffer.mode =
shaka.media.MediaSourceEngine.SourceBufferMode_.SEQUENCE;
}

this.eventManager_.listen(
sourceBuffer, 'error',
() => this.onError_(contentType));
Expand Down
1 change: 1 addition & 0 deletions test/media/media_source_engine_unit.js
Expand Up @@ -639,6 +639,7 @@ describe('MediaSourceEngine', () => {
};
const initObject = new Map();
initObject.set(ContentType.VIDEO, fakeVideoStream);
initObject.set(ContentType.TEXT, fakeTextStream);

await mediaSourceEngine.init(initObject, /* sequenceMode= */ true);

Expand Down

0 comments on commit fb22669

Please sign in to comment.