@@ -1004,7 +1004,17 @@ shaka.media.DrmEngine = class {
10041004
10051005 // If we have configured preferredKeySystems, choose a preferred keySystem
10061006 // if available.
1007- for ( const preferredKeySystem of this . config_ . preferredKeySystems ) {
1007+ let preferredKeySystems = this . config_ . preferredKeySystems ;
1008+ if ( ! preferredKeySystems . length ) {
1009+ // If there is no preference set and we only have one license server, we
1010+ // use this as preference. This is used to override manifests on those
1011+ // that have the embedded license and the browser supports multiple DRMs.
1012+ const servers = shaka . util . MapUtils . asMap ( this . config_ . servers ) ;
1013+ if ( servers . size == 1 ) {
1014+ preferredKeySystems = Array . from ( servers . keys ( ) ) ;
1015+ }
1016+ }
1017+ for ( const preferredKeySystem of preferredKeySystems ) {
10081018 for ( const variant of variants ) {
10091019 const decodingInfo = variant . decodingInfos . find ( ( decodingInfo ) => {
10101020 return decodingInfo . supported &&
@@ -1028,8 +1038,15 @@ shaka.media.DrmEngine = class {
10281038 if ( ! decodingInfo . supported || ! decodingInfo . keySystemAccess ) {
10291039 continue ;
10301040 }
1031- const drmInfos =
1032- drmInfosByKeySystem . get ( decodingInfo . keySystemAccess . keySystem ) ;
1041+ const originalKeySystem = decodingInfo . keySystemAccess . keySystem ;
1042+ if ( preferredKeySystems . includes ( originalKeySystem ) ) {
1043+ continue ;
1044+ }
1045+ let drmInfos = drmInfosByKeySystem . get ( originalKeySystem ) ;
1046+ if ( ! drmInfos && this . config_ . keySystemsMapping [ originalKeySystem ] ) {
1047+ drmInfos = drmInfosByKeySystem . get (
1048+ this . config_ . keySystemsMapping [ originalKeySystem ] ) ;
1049+ }
10331050 for ( const info of drmInfos ) {
10341051 if ( ! ! info . licenseServerUri == shouldHaveLicenseServer ) {
10351052 return decodingInfo . keySystemAccess ;
0 commit comments