Merge pull request #5788 from martell-ventures/loadURL_crossorigin

Add Crossorigin support
This commit is contained in:
Richard Davey 2021-09-20 12:16:14 +01:00 committed by GitHub
commit da3e8b5a25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -811,10 +811,11 @@ var Video = new Class({
* @param {string} url - The URL of the video to load or be streamed.
* @param {string} [loadEvent='loadeddata'] - The load event to listen for. Either `loadeddata`, `canplay` or `canplaythrough`.
* @param {boolean} [noAudio=false] - Does the video have an audio track? If not you can enable auto-playing on it.
* @param {string} [crossOrigin] - The value to use for the `crossOrigin` property in the video load request. Either undefined, `anonymous` or `use-credentials`
*
* @return {this} This Video Game Object for method chaining.
*/
loadURL: function (url, loadEvent, noAudio)
loadURL: function (url, loadEvent, noAudio, crossOrigin)
{
if (loadEvent === undefined) { loadEvent = 'loadeddata'; }
if (noAudio === undefined) { noAudio = false; }
@ -844,6 +845,10 @@ var Video = new Class({
video.setAttribute('playsinline', 'playsinline');
video.setAttribute('preload', 'auto');
if(crossOrigin !== undefined) {
video.setAttribute('crossorigin', crossOrigin);
}
video.addEventListener('error', this._callbacks.error, true);
video.src = url;