From ccd31aa9d9ced89ebec29eecef45b6385be3e7cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 22 May 2025 16:57:50 +0200 Subject: [PATCH] fix(HLS): Fix disableAudio and disableVideo when loading a media playlist (#8642) --- lib/hls/hls_parser.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 3b0dbdfce..131fff966 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -939,18 +939,27 @@ shaka.hls.HlsParser = class { mediaPlaylistType = streamInfo.stream.type; // Wrap the stream from that stream info with a variant. - variants.push({ - id: 0, - language: this.getLanguage_(languageValue), - disabledUntilTime: 0, - primary: true, - audio: mediaPlaylistType == 'audio' ? streamInfo.stream : null, - video: mediaPlaylistType == 'video' ? streamInfo.stream : null, - bandwidth: streamInfo.stream.bandwidth || 0, - allowedByApplication: true, - allowedByKeySystem: true, - decodingInfos: [], - }); + let variantAllowed = true; + if (this.config_.disableAudio && streamInfo.type == 'audio') { + variantAllowed = false; + } else if (this.config_.disableVideo && streamInfo.type == 'video' && + !streamInfo.stream.codecs.includes(',')) { + variantAllowed = false; + } + if (variantAllowed) { + variants.push({ + id: 0, + language: this.getLanguage_(languageValue), + disabledUntilTime: 0, + primary: true, + audio: streamInfo.type == 'audio' ? streamInfo.stream : null, + video: streamInfo.type == 'video' ? streamInfo.stream : null, + bandwidth: streamInfo.stream.bandwidth || 0, + allowedByApplication: true, + allowedByKeySystem: true, + decodingInfos: [], + }); + } } else { this.parseMasterVariables_(variablesTags);