From b9f78d80fa86727c8bb961626eda4ae4ac46d62b Mon Sep 17 00:00:00 2001 From: Walter Seymour Date: Wed, 11 Sep 2024 14:13:26 -0500 Subject: [PATCH] Revert "fix: audio segment on incorrect timeline HLS (#1539)" This reverts commit e4e0c2d465b562d0ad9f6e4c4269d834cd0ccc47. --- src/playlist-controller.js | 26 ++++++++++++++------------ src/segment-loader.js | 3 ++- test/segment-loader.test.js | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/playlist-controller.js b/src/playlist-controller.js index c37425f52..76106be1a 100644 --- a/src/playlist-controller.js +++ b/src/playlist-controller.js @@ -937,25 +937,27 @@ export class PlaylistController extends videojs.EventTarget { this.onEndOfStream(); }); - // There is the possibility of the video segment and the audio segment + // In DASH, 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. - this.timelineChangeController_.on('audioTimelineBehind', () => { - const segmentInfo = this.audioSegmentLoader_.pendingSegment_; + if (this.sourceType_ === 'dash') { + 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 diff --git a/src/segment-loader.js b/src/segment-loader.js index 877209e78..b98321d6a 100644 --- a/src/segment-loader.js +++ b/src/segment-loader.js @@ -475,7 +475,8 @@ const checkAndFixTimelines = (segmentLoader) => { }); if (waitingForTimelineChange && shouldFixBadTimelineChanges(segmentLoader.timelineChangeController_)) { - if (isAudioTimelineBehind(segmentLoader)) { + // Audio being behind should only happen on DASH sources. + if (segmentLoader.sourceType_ === 'dash' && isAudioTimelineBehind(segmentLoader)) { segmentLoader.timelineChangeController_.trigger('audioTimelineBehind'); return; } diff --git a/test/segment-loader.test.js b/test/segment-loader.test.js index 0d90b2259..dafdbd506 100644 --- a/test/segment-loader.test.js +++ b/test/segment-loader.test.js @@ -1789,7 +1789,7 @@ QUnit.module('SegmentLoader', function(hooks) { }); }); - QUnit.test('triggers event when audio timeline is behind main', function(assert) { + QUnit.test('triggers event when DASH audio timeline is behind main', function(assert) { loader.dispose(); loader = new SegmentLoader(LoaderCommonSettings.call(this, { loaderType: 'audio',