Skip to content

Commit

Permalink
fix: audio segment on incorrect timeline HLS (#1539)
Browse files Browse the repository at this point in the history
  • Loading branch information
wseymour15 authored Sep 11, 2024
1 parent 96a3dc5 commit e4e0c2d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
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

0 comments on commit e4e0c2d

Please sign in to comment.