Skip to content

Commit 9dff1b8

Browse files
authored
fix: improve legacy fairplay workflow detection (#235)
1 parent 595f2ad commit 9dff1b8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/plugin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function handleEncryptedEvent(player, event, options, sessions, eventBus,
5959
// Legacy fairplay is the keysystem 'com.apple.fps.1_0'.
6060
// If we are using this keysystem we want to use WebkitMediaKeys.
6161
// This can be initialized manually with initLegacyFairplay().
62-
if (options.keySystems[LEGACY_FAIRPLAY_KEY_SYSTEM] && window.WebKitMediaKeys) {
62+
if (options.keySystems[LEGACY_FAIRPLAY_KEY_SYSTEM] && window.WebKitMediaKeys && player.eme.legacyFairplayIsUsed) {
6363
videojs.log.debug('eme', `Ignoring \'encrypted\' event, using legacy fairplay keySystem ${LEGACY_FAIRPLAY_KEY_SYSTEM}`);
6464
return Promise.resolve();
6565
}
@@ -470,6 +470,7 @@ const eme = function(options = {}) {
470470
}
471471
};
472472

473+
player.eme.legacyFairplayIsUsed = true;
473474
let videoElement = player.tech_.el_;
474475

475476
// Support Safari EME with FairPlay
@@ -484,6 +485,7 @@ const eme = function(options = {}) {
484485
videoElement.removeEventListener('webkitneedkey', webkitNeedKeyEventHandler);
485486
}
486487

488+
player.eme.legacyFairplayIsUsed = false;
487489
videoElement = null;
488490
};
489491

@@ -494,6 +496,7 @@ const eme = function(options = {}) {
494496
return cleanupWebkitNeedKeyHandler;
495497
},
496498
detectSupportedCDMs,
499+
legacyFairplayIsUsed: false,
497500
options
498501
};
499502
};

test/plugin.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,11 @@ QUnit.test('handleEncryptedEvent checks for legacy fairplay', function(assert) {
439439
}
440440
};
441441

442+
// this is set by initLegacyFairplay
443+
this.player.eme.legacyFairplayIsUsed = true;
444+
442445
handleEncryptedEvent(this.player, this.event1, options, sessions).then(() => {
443-
assert.equal(sessions.length, 0, 'did not create a session when no options');
446+
assert.equal(sessions.length, 0, 'did not create a session when legacy fairplay is used');
444447
done();
445448
});
446449
});

0 commit comments

Comments
 (0)