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

feat: getLicense should pass an error to callback if XHR returns 400/500 #99

Merged
merged 5 commits into from
Feb 6, 2020

Conversation

alex-barstow
Copy link
Contributor

@alex-barstow alex-barstow commented Feb 5, 2020

Description

Currently the default getLicense() functions are permissive in that they won't pass an error to the callback if the request returns something in the 4/500 range. The reason being that in some cases, a license server might return a valid license even if the server sends a code in that range.

We decided it makes sense to fix the default behavior to callback with an error for such status codes. If a developer wants to use the old behavior, they can override the default getLicense() function by passing their own with keySystems.

Specific additions

For status codes >= 400 && <= 599, an empty object is passed as the error (callback({})) and emeError() has been modified to call player.error({code: 5, message: null}) in that case, which will use the default MEDIA_ERR_ENCRYPTED message ("The media is encrypted and we do not have the keys to decrypt it.")

Copy link
Contributor

@gesinger gesinger left a comment

Choose a reason for hiding this comment

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

If possible, I think it would be good to add some tests to verify that the error is triggered for a few status codes in the 400 to 599 range.

README.md Outdated
@@ -27,6 +27,7 @@ Maintenance Status: Stable
- [Other DRM Systems](#other-drm-systems)
- [Get License By URL](#get-license-by-url)
- [Get License By Function](#get-license-by-function)
- [A Note on Get License Callbacks](#a-note-on-get-license-callbacks)
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be good to use something like Get License Errors

@alex-barstow alex-barstow merged commit 22de378 into videojs:master Feb 6, 2020
@alex-barstow alex-barstow deleted the add-response-code-errors branch February 6, 2020 16:39
alex-barstow added a commit that referenced this pull request Feb 6, 2020
…00 (#99)

* pass error to license xhr request callbacks for 400 and 500 response codes, include original error object in player error triggered in emeErrorHandler

* update readme

* change letter case

* dont pass original error, use default eme error message for 400/500s, update test

* change readme section title, add unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants