From 9a6dd6948794158a124103bee6c68dd93f4adf85 Mon Sep 17 00:00:00 2001 From: Adam Waldron Date: Fri, 16 Feb 2024 08:53:01 -0800 Subject: [PATCH] docs, logs, comments --- README.md | 9 ++++++++- src/fairplay.js | 1 - src/plugin.js | 15 +++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5d38f18..0d990dd 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ Maintenance Status: Stable - - [Using](#using) - [Initialization](#initialization) - [FairPlay](#fairplay) @@ -43,6 +42,7 @@ Maintenance Status: Stable - [`emeOptions`](#emeoptions) - [`initializeMediaKeys()`](#initializemediakeys) - [`detectSupportedCDMs()`](#detectsupportedcdms) + - [`initLegacyFairplay()`](#initlegacyfairplay) - [Events](#events) - [`licenserequestattempted`](#licenserequestattempted) - [`keystatuschange`](#keystatuschange) @@ -573,6 +573,13 @@ player.eme.detectSupportedCDMs() }); ``` +### `initLegacyFairplay()` + +`player.eme.initLegacyFairplay()` is used to init the `'webkitneedskey'` listener when using `WebKitMediaKeys` in Safari. This is useful because Safari currently supports both the modern `com.apple.fps` keysystem through `MediaKeys` and the legacy `com.apple.fps.1_0` keysystem through `WebKitMediaKeys`. Since this plugin will prefer using modern `MediaKeys` over `WebkitMediaKeys` initializing legacy fairplay can be necessary for media using the legacy `1_0` keysystem. + +```js +player.eme.initLegacyFairplay(); +``` _________________________________________________________ ### Events diff --git a/src/fairplay.js b/src/fairplay.js index 92c2267..d2639c5 100644 --- a/src/fairplay.js +++ b/src/fairplay.js @@ -10,7 +10,6 @@ import window from 'global/window'; import {stringToUint16Array, uint16ArrayToString, getHostnameFromUri, mergeAndRemoveNull} from './utils'; import {httpResponseHandler} from './http-handler.js'; -export const FAIRPLAY_KEY_SYSTEM = 'com.apple.fps'; export const LEGACY_FAIRPLAY_KEY_SYSTEM = 'com.apple.fps.1_0'; const concatInitDataIdAndCertificate = ({initData, id, cert}) => { diff --git a/src/plugin.js b/src/plugin.js index 51dc1e6..07e654a 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -229,15 +229,15 @@ const onPlayerReady = (player, emeError) => { setupSessions(player); const playerOptions = getOptions(player); + // Legacy fairplay is the keysystem 'com.apple.fps.1_0'. + // If we are using this keysystem we want to use WebkitMediaKeys. const isLegacyFairplay = playerOptions.keySystem && playerOptions.keySystem[LEGACY_FAIRPLAY_KEY_SYSTEM]; if (window.MediaKeys && !isLegacyFairplay) { // Support EME 05 July 2016 // Chrome 42+, Firefox 47+, Edge, Safari 12.1+ on macOS 10.14+ player.tech_.el_.addEventListener('encrypted', (event) => { - // TODO convert to videojs.log.debug and add back in - // https://github.com/videojs/video.js/pull/4780 - // videojs.log('eme', 'Received an \'encrypted\' event'); + videojs.log.debug('eme', 'Received an \'encrypted\' event'); setupSessions(player); handleEncryptedEvent(player, event, playerOptions, player.eme.sessions, player.tech_) .catch(emeError); @@ -251,9 +251,7 @@ const onPlayerReady = (player, emeError) => { // Functionally speaking, there should be no discernible difference between // the behavior of IE11 and those of other browsers. player.tech_.el_.addEventListener('msneedkey', (event) => { - // TODO convert to videojs.log.debug and add back in - // https://github.com/videojs/video.js/pull/4780 - // videojs.log('eme', 'Received an \'msneedkey\' event'); + videojs.log.debug('eme', 'Received an \'msneedkey\' event'); setupSessions(player); try { handleMsNeedKeyEvent(event, playerOptions, player.eme.sessions, player.tech_); @@ -358,10 +356,7 @@ const eme = function(options = {}) { initLegacyFairplay() { const playerOptions = getOptions(player); const handleFn = (event) => { - // TODO convert to videojs.log.debug and add back in - // https://github.com/videojs/video.js/pull/4780 - // videojs.log('eme', 'Received a \'webkitneedkey\' event'); - + videojs.log.debug('eme', 'Received a \'webkitneedkey\' event'); // TODO it's possible that the video state must be cleared if reusing the same video // element between sources setupSessions(player);