Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix conflicts with multiple installations #71

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class EmeEncryptionSchemePolyfill {
* @export
*/
static install() {
if (EmeEncryptionSchemePolyfill.originalRMKSA_) {
if (EmeEncryptionSchemePolyfill.originalRMKSA_ ||
navigator['emeEncryptionSchemePolyfilled']) {
console.debug('EmeEncryptionSchemePolyfill: Already installed.');
return;
}
Expand All @@ -53,6 +54,11 @@ class EmeEncryptionSchemePolyfill {
'Waiting to detect encryptionScheme support.');
navigator.requestMediaKeySystemAccess =
EmeEncryptionSchemePolyfill.probeRMKSA_;

// Mark EME as polyfilled. This keeps us from running into conflicts
// between multiple versions of this (compiled Shaka lib vs
// uncompiled source).
navigator['emeEncryptionSchemePolyfilled'] = true;
}

/**
Expand Down Expand Up @@ -240,7 +246,8 @@ class McEncryptionSchemePolyfill {
* @export
*/
static install() {
if (McEncryptionSchemePolyfill.originalDecodingInfo_) {
if (McEncryptionSchemePolyfill.originalDecodingInfo_ ||
navigator['mediaCapabilitiesEncryptionSchemePolyfilled']) {
console.debug('McEncryptionSchemePolyfill: Already installed.');
return;
}
Expand All @@ -259,6 +266,11 @@ class McEncryptionSchemePolyfill {
'Waiting to detect encryptionScheme support.');
navigator.mediaCapabilities.decodingInfo =
McEncryptionSchemePolyfill.probeDecodingInfo_;

// Mark MediaCapabilities as polyfilled. This keeps us from running into
// conflicts between multiple versions of this (compiled Shaka lib vs
// uncompiled source).
navigator['mediaCapabilitiesEncryptionSchemePolyfilled'] = true;
}

/**
Expand Down
Loading