From 8ee4eba4ad4453a695682422b2c7ad2b4e7dcf28 Mon Sep 17 00:00:00 2001 From: Vincent Valot Date: Mon, 14 Nov 2022 09:47:35 +0100 Subject: [PATCH] add documentation --- docs/tutorials/drm-config.md | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/docs/tutorials/drm-config.md b/docs/tutorials/drm-config.md index 1f34196ce5..ee74d35f54 100644 --- a/docs/tutorials/drm-config.md +++ b/docs/tutorials/drm-config.md @@ -209,6 +209,62 @@ you should provide an empty string as robustness Values for other key systems are not known to us at this time. +#### Re-use persistent license DRM for online playback + +If your DRM provider configuration allows you to deliver persistent license, +you could re-use the created MediaKeys session for the next online playback. + +Configure Shaka to start DRM sessions with the `persistent-license` type +instead of the `temporary` one: + +```js +player.configure({ + drm: { + advanced: { + 'com.widevine.alpha': { + 'sessionType': 'persistent-license' + } + } + } +}); +``` + +**Using `persistent-license` might now work on every devices, use this feature +carefully.** + +When the playback starts, you can retrieve the sessions metadata: + +```js +const activeDrmSessions = this.player.getActiveSessionsMetadata(); +const persistentDrmSessions = activeDrmSessions.filter( + ({ sessionType }) => sessionType === 'persistent-license'); + +// Add your own storage mechanism here, give it an unique known identifier for +// the playing video +``` + +When starting the same video again, retrieve the metadata from the storage, and +set it back to Shaka's configuration. + +Shaka will load the given DRM persistent sessions and will only request a +license if some keys are missing for the content. + +```js +player.configure({ + drm: { + persistentSessionOnlinePlayback: true, + persistentSessionsMetadata: [{ + sessionId: 'deadbeefdeadbeefdeadbeefdeadbeef', + initData: new InitData(0), + initDataType: 'cenc' + }] + } +}); +``` + +NB: Shaka doesn't provide a out-of-the-box storage mechanism for the sessions +metadata. + #### Continue the Tutorials Next, check out {@tutorial license-server-auth}.