From ef9fa231bad5c38608d16dce34e47742029d9d82 Mon Sep 17 00:00:00 2001 From: Garrett Singer Date: Wed, 1 Apr 2020 08:54:02 -0400 Subject: [PATCH] feat: add support for setting persistentState in supportedConfigurations (#102) --- README.md | 2 +- src/eme.js | 5 +++++ test/eme.test.js | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 17d470a..b35ddf7 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,7 @@ Below is an example of using one of these DRM systems and custom `getLicense()` In addition to `audioContentType` and `videoContentType` posted above, it is possible to directly provide the `supportedConfigurations` array to use for the `requestMediaKeySystemAccess` call. This allows for the entire range of options specified by the [MediaKeySystemConfiguration] object. -Note that if `supportedConfigurations` is provided, it will override `audioContentType`, `videoContentType`, `audioRobustness`, and `videoRobustness`. +Note that if `supportedConfigurations` is provided, it will override `audioContentType`, `videoContentType`, `audioRobustness`, `videoRobustness`, and `persistentState`. Example: diff --git a/src/eme.js b/src/eme.js index 92614e3..d86e1b4 100644 --- a/src/eme.js +++ b/src/eme.js @@ -25,6 +25,7 @@ export const getSupportedConfigurations = (keySystemOptions) => { const audioRobustness = keySystemOptions.audioRobustness; const videoContentType = keySystemOptions.videoContentType; const videoRobustness = keySystemOptions.videoRobustness; + const persistentState = keySystemOptions.persistentState; if (audioContentType || audioRobustness) { supportedConfiguration.audioCapabilities = [ @@ -44,6 +45,10 @@ export const getSupportedConfigurations = (keySystemOptions) => { ]; } + if (persistentState) { + supportedConfiguration.persistentState = persistentState; + } + return [supportedConfiguration]; }; diff --git a/test/eme.test.js b/test/eme.test.js index ab31d78..2670e11 100644 --- a/test/eme.test.js +++ b/test/eme.test.js @@ -1105,6 +1105,14 @@ QUnit.test('includes audio and video content types and robustness', function(ass ); }); +QUnit.test('includes persistentState', function(assert) { + assert.deepEqual( + getSupportedConfigurations({ persistentState: 'optional' }), + [{ persistentState: 'optional' }], + 'included persistentState' + ); +}); + QUnit.test('uses supportedConfigurations directly if provided', function(assert) { assert.deepEqual( getSupportedConfigurations({