Skip to content

Commit f1bdd17

Browse files
committed
[ISSUE 1458] Allow BLOB urls when loading audio files
1 parent 5f12e18 commit f1bdd17

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/loader/Loader.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,8 @@ Phaser.Loader.prototype = {
616616
* Add a new audio file to the loader.
617617
*
618618
* @method Phaser.Loader#audio
619-
* @param {string} key - Unique asset key of the audio file.
620-
* @param {Array|string} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ] or a single string containing just one URL.
619+
* @param {string} key - Unique asset key of the audio file. This can be a BLOB url string.
620+
* @param {Array|string} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ] or a single string containing just one URL. BLOB urls are supported, but note that Phaser will not validate the audio file's type if a BLOB is provided; the user should ensure that a BLOB url is playable.
621621
* @param {boolean} autoDecode - When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process.
622622
* @return {Phaser.Loader} This Loader instance.
623623
*/
@@ -1406,6 +1406,12 @@ Phaser.Loader.prototype = {
14061406
for (var i = 0; i < urls.length; i++)
14071407
{
14081408
extension = urls[i].toLowerCase();
1409+
1410+
if (extension.substr(0,5) === "blob:")
1411+
{
1412+
return urls[i];
1413+
}
1414+
14091415
extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1);
14101416

14111417
if (extension.indexOf("?") >= 0)

0 commit comments

Comments
 (0)