Skip to content

Commit ccd31aa

Browse files
authored
fix(HLS): Fix disableAudio and disableVideo when loading a media playlist (#8642)
1 parent f86245c commit ccd31aa

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

lib/hls/hls_parser.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -939,18 +939,27 @@ shaka.hls.HlsParser = class {
939939
mediaPlaylistType = streamInfo.stream.type;
940940

941941
// Wrap the stream from that stream info with a variant.
942-
variants.push({
943-
id: 0,
944-
language: this.getLanguage_(languageValue),
945-
disabledUntilTime: 0,
946-
primary: true,
947-
audio: mediaPlaylistType == 'audio' ? streamInfo.stream : null,
948-
video: mediaPlaylistType == 'video' ? streamInfo.stream : null,
949-
bandwidth: streamInfo.stream.bandwidth || 0,
950-
allowedByApplication: true,
951-
allowedByKeySystem: true,
952-
decodingInfos: [],
953-
});
942+
let variantAllowed = true;
943+
if (this.config_.disableAudio && streamInfo.type == 'audio') {
944+
variantAllowed = false;
945+
} else if (this.config_.disableVideo && streamInfo.type == 'video' &&
946+
!streamInfo.stream.codecs.includes(',')) {
947+
variantAllowed = false;
948+
}
949+
if (variantAllowed) {
950+
variants.push({
951+
id: 0,
952+
language: this.getLanguage_(languageValue),
953+
disabledUntilTime: 0,
954+
primary: true,
955+
audio: streamInfo.type == 'audio' ? streamInfo.stream : null,
956+
video: streamInfo.type == 'video' ? streamInfo.stream : null,
957+
bandwidth: streamInfo.stream.bandwidth || 0,
958+
allowedByApplication: true,
959+
allowedByKeySystem: true,
960+
decodingInfos: [],
961+
});
962+
}
954963
} else {
955964
this.parseMasterVariables_(variablesTags);
956965

0 commit comments

Comments
 (0)