Skip to content

Commit e4e0c2d

Browse files
authored
fix: audio segment on incorrect timeline HLS (#1539)
1 parent 96a3dc5 commit e4e0c2d

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

src/playlist-controller.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -937,27 +937,25 @@ export class PlaylistController extends videojs.EventTarget {
937937
this.onEndOfStream();
938938
});
939939

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

949-
if (!segmentInfo || !segmentInfo.segment || !segmentInfo.segment.syncInfo) {
950-
return;
951-
}
948+
if (!segmentInfo || !segmentInfo.segment || !segmentInfo.segment.syncInfo) {
949+
return;
950+
}
952951

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

958-
this.tech_.setCurrentTime(newTime);
959-
});
960-
}
957+
this.tech_.setCurrentTime(newTime);
958+
});
961959

962960
this.mainSegmentLoader_.on('earlyabort', (event) => {
963961
// never try to early abort with the new ABR algorithm

src/segment-loader.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ const checkAndFixTimelines = (segmentLoader) => {
475475
});
476476

477477
if (waitingForTimelineChange && shouldFixBadTimelineChanges(segmentLoader.timelineChangeController_)) {
478-
// Audio being behind should only happen on DASH sources.
479-
if (segmentLoader.sourceType_ === 'dash' && isAudioTimelineBehind(segmentLoader)) {
478+
if (isAudioTimelineBehind(segmentLoader)) {
480479
segmentLoader.timelineChangeController_.trigger('audioTimelineBehind');
481480
return;
482481
}

test/segment-loader.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ QUnit.module('SegmentLoader', function(hooks) {
17891789
});
17901790
});
17911791

1792-
QUnit.test('triggers event when DASH audio timeline is behind main', function(assert) {
1792+
QUnit.test('triggers event when audio timeline is behind main', function(assert) {
17931793
loader.dispose();
17941794
loader = new SegmentLoader(LoaderCommonSettings.call(this, {
17951795
loaderType: 'audio',

0 commit comments

Comments
 (0)