Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: audio segment on incorrect timeline HLS #1539

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/playlist-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,27 +937,25 @@ export class PlaylistController extends videojs.EventTarget {
this.onEndOfStream();
});

// In DASH, there is the possibility of the video segment and the audio segment
// There is the possibility of the video segment and the audio segment
// at a current time to be on different timelines. When this occurs, the player
// forwards playback to a point where these two segment types are back on the same
// timeline. This time will be just after the end of the audio segment that is on
// a previous timeline.
if (this.sourceType_ === 'dash') {
this.timelineChangeController_.on('audioTimelineBehind', () => {
const segmentInfo = this.audioSegmentLoader_.pendingSegment_;
this.timelineChangeController_.on('audioTimelineBehind', () => {
const segmentInfo = this.audioSegmentLoader_.pendingSegment_;

if (!segmentInfo || !segmentInfo.segment || !segmentInfo.segment.syncInfo) {
return;
}
if (!segmentInfo || !segmentInfo.segment || !segmentInfo.segment.syncInfo) {
return;
}

// Update the current time to just after the faulty audio segment.
// This moves playback to a spot where both audio and video segments
// are on the same timeline.
const newTime = segmentInfo.segment.syncInfo.end + 0.01;
// Update the current time to just after the faulty audio segment.
// This moves playback to a spot where both audio and video segments
// are on the same timeline.
const newTime = segmentInfo.segment.syncInfo.end + 0.01;

this.tech_.setCurrentTime(newTime);
});
}
this.tech_.setCurrentTime(newTime);
});

this.mainSegmentLoader_.on('earlyabort', (event) => {
// never try to early abort with the new ABR algorithm
Expand Down
3 changes: 1 addition & 2 deletions src/segment-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ const checkAndFixTimelines = (segmentLoader) => {
});

if (waitingForTimelineChange && shouldFixBadTimelineChanges(segmentLoader.timelineChangeController_)) {
// Audio being behind should only happen on DASH sources.
if (segmentLoader.sourceType_ === 'dash' && isAudioTimelineBehind(segmentLoader)) {
if (isAudioTimelineBehind(segmentLoader)) {
segmentLoader.timelineChangeController_.trigger('audioTimelineBehind');
return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/segment-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ QUnit.module('SegmentLoader', function(hooks) {
});
});

QUnit.test('triggers event when DASH audio timeline is behind main', function(assert) {
QUnit.test('triggers event when audio timeline is behind main', function(assert) {
loader.dispose();
loader = new SegmentLoader(LoaderCommonSettings.call(this, {
loaderType: 'audio',
Expand Down
Loading