2016-01-29 27 views
5

Próbuję dowiedzieć się, jak określić, która przeglądarka systemu DRM jest używana. W rzeczywistości tylko chrome mówi, że używa "com.widevine.alpha", gdzie IE & Safari (Win) wyświetla błąd na "requestMediaKeySystemAccess", a firefox nawet nie próbuje powiedzieć, że używa "com.adobe.acccess" =]Określanie systemu DRM obsługiwanego przez przeglądarkę

Czy istnieje jakieś rozwiązanie, takie jak Modernizr lub podobne, aby uzyskać klucz Key System?

+0

sprawdź ten artykuł, który napisałem niedawno: http://aameer.github.io/articles/digital-rights-management-multi-drm/ wyjaśnia szczegółowo o tym, jak osiągnąć multi-drm, sprawdź dział o obecny status – Aameer

Odpowiedz

4

Istnieje kilka witryn, które oferują taką kontrolę, jak dash-player.com/browser-capabilities/ po bliżej przyjrzeć się jak to zrobić, można użyć coś podobnego do:

// EME Check 
 
var keySystems = { 
 
    widevine: ['com.widevine.alpha'], 
 
    playready: ['com.microsoft.playready', 'com.youtube.playready'], 
 
    clearkey: ['webkit-org.w3.clearkey', 'org.w3.clearkey'], 
 
    primetime: ['com.adobe.primetime', 'com.adobe.access'], 
 
    fairplay: ['com.apple.fairplay'] 
 
}; 
 
var keySystemsCount = (function() { 
 
    var count = 0; 
 
    for (keysys in keySystems) { 
 
    if (keySystems.hasOwnProperty(keysys)) { 
 
     count += keySystems[keysys].length; 
 
    } 
 
    } 
 
    return count; 
 
})(); 
 

 
var testVideoElement = document.createElement('video'); 
 
var supportedSystems = []; 
 
var unsupportedSystems = []; 
 

 
var supportsEncryptedMediaExtension = function() { 
 
    if (!testVideoElement.mediaKeys) { 
 
    if (window.navigator.requestMediaKeySystemAccess) { 
 
     if (typeof window.navigator.requestMediaKeySystemAccess === 'function') { 
 
     console.log('found default EME'); 
 
     hasEME = true; 
 
     var isKeySystemSupported = function (keySystem) { 
 
      var config = [{initDataTypes: ['cenc']}]; 
 
      if (window.navigator.requestMediaKeySystemAccess) { 
 
      window.navigator.requestMediaKeySystemAccess(keySystem, config).then(function (keySystemAccess) { 
 
       supportedSystems.push(keySystem); 
 
      }).catch(function() { 
 
       unsupportedSystems.push(keySystem); 
 
      }); 
 
      } 
 
     }; 
 
     var keysys, dummy, i; 
 
     for (keysys in keySystems) { 
 
      if (keySystems.hasOwnProperty(keysys)) { 
 
      for (dummy in keySystems[keysys]) { 
 
       isKeySystemSupported(keySystems[keysys][dummy]); 
 
      } 
 
      } 
 
     } 
 
     } 
 
    } else if (window.MSMediaKeys) { 
 
     if (typeof window.MSMediaKeys === 'function') { 
 
     console.log('found MS-EME'); 
 
     hasEME = true; 
 
     var keysys, dummy, i; 
 
     for (keysys in keySystems) { 
 
      if (keySystems.hasOwnProperty(keysys)) { 
 
      for (dummy in keySystems[keysys]) { 
 
       if (MSMediaKeys.isTypeSupported(keySystems[keysys][dummy])) { 
 
       supportedSystems.push(keySystems[keysys][dummy]); 
 
       } else { 
 
       unsupportedSystems.push(keySystems[keysys][dummy]); 
 
       } 
 
      } 
 
      } 
 
     } 
 
     } 
 
    } else if (testVideoElement.webkitGenerateKeyRequest) { 
 
     if (typeof testVideoElement.webkitGenerateKeyRequest === 'function') { 
 
     console.log('found WebKit EME'); 
 
     hasEME = true; 
 
     var keysys, dummy, i; 
 
     for (keysys in keySystems) { 
 
      if (keySystems.hasOwnProperty(keysys)) { 
 
      for (dummy in keySystems[keysys]) { 
 
       if (testVideoElement.canPlayType('video/mp4', keySystems[keysys][dummy])) { 
 
       supportedSystems.push(keySystems[keysys][dummy]); 
 
       } else { 
 
       unsupportedSystems.push(keySystems[keysys][dummy]); 
 
       } 
 
      } 
 
      } 
 
     } 
 
     } 
 
    } else { 
 
     console.log('no supported EME implementation found'); 
 
     hasEME = false; 
 
    } 
 
    } 
 
}

Wystarczy uruchomić supportsEncryptedMediaExtension() i supportedSystems zostaną wypełnione żądanymi informacjami.

+1

To jest świetne! Gdzie znajdziesz listę kluczowych ciągów systemowych? Wiem, że 'org.w3.clearkey' pochodzi ze specyfikacji w3 - https://w3c.github.io/encrypted-media/#common-key-systems -. Ale mam problem ze śledzeniem, skąd pochodzą inni. – Boushley

+1

Wygląda na to, że Safari wydaje się niezdefiniowany we właściwości 'webkitGenerateKeyRequest'. Czy ktoś eksperymentuje z tym problemem? Dzięki –

1

Oprócz informacji wymienionych tutaj, chcę wspomnieć, że w Chrome, niezależnie od tego, czy używasz https, czy też nie, wpłynie to na dostępność funkcji navigator.requestMediaKeySystemAccess.

w środowisku rozwoju, który prawdopodobnie jest uruchomiony na http, navigator.requestMediaKeySystemAccess powróci undefined dla Chrome natomiast ten sam kod zwróci funkcję w Firefox.

W swoim środowisku produkcyjnym, który ma https, navigator.requestMediaKeySystemAccess powróci funkcję zarówno w Chrome i Firefox.