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);