Fix loading audio and video with blob urls

Passing a blob url as the second parameter to `this.load.audio` or
`this.load.video` would cause Phaser to load a different url.
Additionally, `this.load.path` would incorrectly be prepended to the
url.

`AudioFile.getAudioURL` and `VideoFile.getVideoURL`, are expected to
return an object with two properties; url and type. However when passed
a blob url they return a string. The return value's
`url` property is inspected to get the url. For strings' the property is
`undefined`. If the url property is undefined then a url derived from
the asset key is used instead.
This commit is contained in:
aucguy 2020-03-22 22:21:27 -05:00
parent 88b088b6a2
commit ff886b001e
3 changed files with 9 additions and 3 deletions

View file

@ -94,7 +94,7 @@ var File = new Class({
{
this.url = loader.path + loadKey + '.' + GetFastValue(fileConfig, 'extension', '');
}
else if (typeof(this.url) !== 'function')
else if (typeof(this.url) !== 'function' && this.url.indexOf('blob:') !== 0 && this.url.indexOf('data:') !== 0)
{
this.url = loader.path + this.url;
}

View file

@ -145,7 +145,10 @@ AudioFile.getAudioURL = function (game, urls)
if (url.indexOf('blob:') === 0 || url.indexOf('data:') === 0)
{
return url;
return {
url: url,
type: ''
};
}
var audioType = url.match(/\.([a-zA-Z0-9]+)($|\?)/);

View file

@ -261,7 +261,10 @@ VideoFile.getVideoURL = function (game, urls)
if (url.indexOf('blob:') === 0)
{
return url;
return {
url: url,
type: ''
};
}
var videoType;