videojs / videojs-contrib-eme

Supports Encrypted Media Extensions for playback of encrypted content in Video.js
Other
203 stars 72 forks source link

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

Closed alex-barstow closed 4 years ago

alex-barstow commented 4 years ago

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.")