From 3db710c6a9969b906bce0ed2843e272b8079454a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Tue, 24 Dec 2024 13:10:40 +0100 Subject: [PATCH] fix(HLS): Do not use EXT-X-PROGRAM-DATE-TIME on vod when there is only video or audio (#7802) Fixes https://github.com/shaka-project/shaka-player/issues/7774 Backported to v4.12.x --- lib/hls/hls_parser.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 3f79affcb1..21f89276b2 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -2582,12 +2582,23 @@ shaka.hls.HlsParser = class { } } this.notifySegmentsForStreams_(streamInfos.map((s) => s.stream)); - const liveWithNoProgramaDateTime = + + const activeStreamInfos = Array.from(this.uriToStreamInfosMap_.values()) + .filter((s) => s.stream.segmentIndex); + const ContentType = shaka.util.ManifestParserUtils.ContentType; + const hasAudio = + activeStreamInfos.some((s) => s.stream.type == ContentType.AUDIO); + const hasVideo = + activeStreamInfos.some((s) => s.stream.type == ContentType.VIDEO); + + const liveWithNoProgramDateTime = this.isLive_() && !this.usesProgramDateTime_; + const vodWithOnlyAudioOrVideo = !this.isLive_() && + this.usesProgramDateTime_ && !(hasAudio && hasVideo); if (this.config_.hls.ignoreManifestProgramDateTime || - liveWithNoProgramaDateTime) { + liveWithNoProgramDateTime || vodWithOnlyAudioOrVideo) { this.syncStreamsWithSequenceNumber_( - streamInfos, liveWithNoProgramaDateTime); + streamInfos, liveWithNoProgramDateTime); } else { this.syncStreamsWithProgramDateTime_(streamInfos); if (this.config_.hls.ignoreManifestProgramDateTimeForTypes.length > 0) {