feat: getLicense should pass an error to callback if XHR returns 400/500 #99
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 withkeySystems
.Specific additions
For status codes >= 400 && <= 599, an empty object is passed as the error (
callback({})
) andemeError()
has been modified to callplayer.error({code: 5, message: null})
in that case, which will use the defaultMEDIA_ERR_ENCRYPTED
message ("The media is encrypted and we do not have the keys to decrypt it.")