Skip to content

Commit

Permalink
feat: add support for setting persistentState in supportedConfigurati…
Browse files Browse the repository at this point in the history
…ons (#102)
  • Loading branch information
gesinger committed Apr 1, 2020
1 parent 3085f3f commit ef9fa23
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
5 changes: 5 additions & 0 deletions src/eme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -44,6 +45,10 @@ export const getSupportedConfigurations = (keySystemOptions) => {
];
}

if (persistentState) {
supportedConfiguration.persistentState = persistentState;
}

return [supportedConfiguration];
};

Expand Down
8 changes: 8 additions & 0 deletions test/eme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit ef9fa23

Please sign in to comment.