Skip to content

Commit

Permalink
fix: pass along preset PlayReady init data (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
forbesjo authored Oct 16, 2018
1 parent 9dad1dd commit 746e5ed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
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

0 comments on commit 746e5ed

Please sign in to comment.