Skip to content

Instantly share code, notes, and snippets.

@kypflug

kypflug/eme-2.js Secret

Created October 14, 2015 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kypflug/b78e8973bfced8b09845 to your computer and use it in GitHub Desktop.
Save kypflug/b78e8973bfced8b09845 to your computer and use it in GitHub Desktop.
// Try PlayReady
navigator.requestMediaKeySystemAccess('com.microsoft.playready', [{
initDataTypes: ['keyids', 'cenc'],
audioCapabilities: [{ contentType: 'audio/mp4; codecs="mp4a"' }],
videoCapabilities: [{ contentType: 'video/mp4; codecs="avc1"' }]
}
]).then(function (keySystemAccess) { /* Promise succeeded. Call createMediaKeys */},function () {
// Promise was rejected for PlayReady. Try Widevine.
navigator.requestMediaKeySystemAccess('com.widevine.alpha', [{
initDataTypes: ['keyids', 'webm'],
audioCapabilities: [{ contentType: 'audio/webm; codecs="opus"'}],
videoCapabilities: [{ contentType: 'video/webm; codecs="vp9"'}]
}
]).then(function (keySystemAccess) { /* Promise succeeded. Call createMediaKeys */ }, function () {
// Neither Promise succeeded. Browser does not support Widevine or PlayReady
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment