Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass along preset PlayReady init data #60

Merged
merged 1 commit into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,19 @@ export const handleMsNeedKeyEvent = (event, options, sessions, eventBus) => {
return;
}

sessions.push({ playready: true });
let initData = event.initData;

// Use existing init data from options if provided
if (options.keySystems[PLAYREADY_KEY_SYSTEM] &&
options.keySystems[PLAYREADY_KEY_SYSTEM].pssh) {
initData = options.keySystems[PLAYREADY_KEY_SYSTEM].pssh;
}

sessions.push({ playready: true, initData });

msPrefixed({
video: event.target,
initData: event.initData,
initData,
options,
eventBus
});
Expand Down
15 changes: 15 additions & 0 deletions test/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,21 @@ QUnit.test('handleEncryptedEvent uses predefined init data', function(assert) {
});
});

QUnit.test('handleMsNeedKeyEvent uses predefined init data', function(assert) {
const options = {
keySystems: {
'com.microsoft.playready': {
pssh: this.initData1
}
}
};
const sessions = [];

handleMsNeedKeyEvent(this.event2, options, sessions);
assert.equal(sessions.length, 1, 'created a session when keySystems in options');
assert.deepEqual(sessions[0].initData, this.initData1, 'captured initData in the session');
});

QUnit.test('handleMsNeedKeyEvent checks for required options', function(assert) {
const event = {
// mock video target to prevent errors since it's a pain to mock out the continuation
Expand Down