Skip to content

Commit

Permalink
docs, logs, comments
Browse files Browse the repository at this point in the history
  • Loading branch information
adrums86 committed Feb 16, 2024
1 parent b5dbacb commit 9a6dd69
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Maintenance Status: Stable
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Using](#using)
- [Initialization](#initialization)
- [FairPlay](#fairplay)
Expand Down Expand Up @@ -43,6 +42,7 @@ Maintenance Status: Stable
- [`emeOptions`](#emeoptions)
- [`initializeMediaKeys()`](#initializemediakeys)
- [`detectSupportedCDMs()`](#detectsupportedcdms)
- [`initLegacyFairplay()`](#initlegacyfairplay)
- [Events](#events)
- [`licenserequestattempted`](#licenserequestattempted)
- [`keystatuschange`](#keystatuschange)
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/fairplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) => {
Expand Down
15 changes: 5 additions & 10 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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_);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9a6dd69

Please sign in to comment.