@@ -55,6 +55,7 @@ goog.require('shaka.util.Functional');
55
55
goog . require ( 'shaka.util.IDestroyable' ) ;
56
56
goog . require ( 'shaka.util.LanguageUtils' ) ;
57
57
goog . require ( 'shaka.util.ManifestParserUtils' ) ;
58
+ goog . require ( 'shaka.util.MapUtils' ) ;
58
59
goog . require ( 'shaka.util.MediaReadyState' ) ;
59
60
goog . require ( 'shaka.util.MimeUtils' ) ;
60
61
goog . require ( 'shaka.util.Mutex' ) ;
@@ -7991,6 +7992,9 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
7991
7992
7992
7993
// Only filter tracks for keys if we have some key statuses to look at.
7993
7994
if ( keyIds . length ) {
7995
+ const currentKeySystem = this . keySystem ( ) ;
7996
+ const clearKeys = shaka . util . MapUtils . asMap ( this . config_ . drm . clearKeys ) ;
7997
+
7994
7998
for ( const variant of this . manifest_ . variants ) {
7995
7999
const streams = shaka . util . StreamUtils . getVariantStreams ( variant ) ;
7996
8000
@@ -8000,16 +8004,42 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
8000
8004
// Only update if we have key IDs for the stream. If the keys aren't
8001
8005
// all present, then the track should be restricted.
8002
8006
if ( stream . keyIds . size ) {
8003
- variant . allowedByKeySystem = true ;
8004
-
8005
- for ( const keyId of stream . keyIds ) {
8006
- const keyStatus = keyStatusMap [ isGlobalStatus ? '00' : keyId ] ;
8007
- if ( keyStatus || this . drmEngine_ . hasManifestInitData ( ) ) {
8008
- variant . allowedByKeySystem = variant . allowedByKeySystem &&
8009
- ! ! keyStatus && ! restrictedStatuses . includes ( keyStatus ) ;
8010
- }
8011
- }
8012
- }
8007
+ // If we are not using clearkeys, and the stream has drmInfos we
8008
+ // only want to check the keyIds of the keySystem we are using.
8009
+ // Other keySystems might have other keyIds that might not be
8010
+ // valid in this case. This can happen in HLS if the manifest
8011
+ // has Widevine with keyIds and PlayReady without keyIds and we are
8012
+ // using PlayReady.
8013
+ if ( stream . drmInfos . length && ! clearKeys . size ) {
8014
+ for ( const drmInfo of stream . drmInfos ) {
8015
+ if ( drmInfo . keyIds . size &&
8016
+ drmInfo . keySystem == currentKeySystem ) {
8017
+ variant . allowedByKeySystem = true ;
8018
+
8019
+ for ( const keyId of drmInfo . keyIds ) {
8020
+ const keyStatus =
8021
+ keyStatusMap [ isGlobalStatus ? '00' : keyId ] ;
8022
+ if ( keyStatus || this . drmEngine_ . hasManifestInitData ( ) ) {
8023
+ variant . allowedByKeySystem =
8024
+ variant . allowedByKeySystem &&
8025
+ ! ! keyStatus &&
8026
+ ! restrictedStatuses . includes ( keyStatus ) ;
8027
+ } // if (keyStatus || this.drmEngine_.hasManifestInitData())
8028
+ } // for (const keyId of drmInfo.keyIds)
8029
+ } // if (drmInfo.keyIds.size && ...
8030
+ } // for (const drmInfo of stream.drmInfos
8031
+ } else {
8032
+ variant . allowedByKeySystem = true ;
8033
+
8034
+ for ( const keyId of stream . keyIds ) {
8035
+ const keyStatus = keyStatusMap [ isGlobalStatus ? '00' : keyId ] ;
8036
+ if ( keyStatus || this . drmEngine_ . hasManifestInitData ( ) ) {
8037
+ variant . allowedByKeySystem = variant . allowedByKeySystem &&
8038
+ ! ! keyStatus && ! restrictedStatuses . includes ( keyStatus ) ;
8039
+ }
8040
+ } // for (const keyId of stream.keyIds)
8041
+ } // if (stream.drmInfos.length && !clearKeys.size)
8042
+ } // if (stream.keyIds.size)
8013
8043
8014
8044
if ( originalAllowed != variant . allowedByKeySystem ) {
8015
8045
tracksChanged = true ;
0 commit comments