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: Use correct callback function signature for PlayReady license request callbacks. #81

Merged
merged 1 commit into from
May 1, 2019
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ By default, videojs-contrib-eme is not able to decrypt any audio/video.

In order to decrypt audio/video, a user must pass in either relevant license URIs, or methods specific to a source and its combination of key system and codec. These are provided to the plugin via either videojs-contrib-eme's plugin options or source options.

If you're new to DRM on the web, read [about how EME is used to play protected content on the web](https://developers.google.com/web/fundamentals/media/eme).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this because it seems like a useful thing for helping users understand the purpose of this plugin.

### Initialization

The videojs-contrib-eme plugin must be initialized before a source is loaded into the player:
Expand Down
9 changes: 8 additions & 1 deletion src/playready.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,12 @@ export const requestPlayreadyLicense = (keySystemOptions, messageBuffer, emeOpti
headers,
body: message,
responseType: 'arraybuffer'
}, callback);
}, (err, response, responseBody) => {
if (err) {
callback(err);
return;
}

callback(null, responseBody);
});
};
14 changes: 7 additions & 7 deletions test/ms-prefixed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ QUnit.test('calls getKey when provided on key message', function(assert) {
assert.equal(this.session.keys[0], 'a key', 'added correct key to session');

getKeyCallback = (callback) => {
callback('an error', 'an errored key');
callback('an error', {}, 'an errored key');
};

this.session.trigger({
Expand Down Expand Up @@ -253,14 +253,14 @@ QUnit.test('makes request when nothing provided on key message', function(assert
body: utils.stringToArrayBuffer('key value')
};

xhrCalls[0].callback('an error', response);
xhrCalls[0].callback('an error', {}, response);

assert.equal(errorMessage,
'Unable to request key from url: destination-url',
'triggers mskeyerror on event bus when callback has an error');
assert.equal(this.session.keys.length, 0, 'no key added to session');

xhrCalls[0].callback(null, response);
xhrCalls[0].callback(null, {}, response);

assert.equal(this.session.keys.length, 1, 'key added to session');
assert.deepEqual(this.session.keys[0],
Expand Down Expand Up @@ -372,14 +372,14 @@ QUnit.test('makes request with provided url string on key message', function(ass
body: utils.stringToArrayBuffer('key value')
};

xhrCalls[0].callback('an error', response);
xhrCalls[0].callback('an error', {}, response);

assert.equal(errorMessage,
'Unable to request key from url: provided-url',
'triggers mskeyerror on event bus when callback has an error');
assert.equal(this.session.keys.length, 0, 'no key added to session');

xhrCalls[0].callback(null, response);
xhrCalls[0].callback(null, {}, response);

assert.equal(this.session.keys.length, 1, 'key added to session');
assert.deepEqual(this.session.keys[0],
Expand Down Expand Up @@ -456,15 +456,15 @@ QUnit.test('makes request with provided url on key message', function(assert) {
body: utils.stringToArrayBuffer('key value')
};

xhrCalls[0].callback('an error', response);
xhrCalls[0].callback('an error', {}, response);

assert.equal(callCounts.licenseRequestAttempts, 1, 'license request event triggered');
assert.equal(errorMessage,
'Unable to request key from url: provided-url',
'triggers mskeyerror on event bus when callback has an error');
assert.equal(this.session.keys.length, 0, 'no key added to session');

xhrCalls[0].callback(null, response);
xhrCalls[0].callback(null, {}, response);

assert.equal(callCounts.licenseRequestAttempts, 2,
'second license request event triggered');
Expand Down