Skip to content

Commit 2641e2e

Browse files
committed
Merge pull request phaserjs#1462 from aressler38/dev
Support BLOB urls for audio files
2 parents 9b967d1 + c998463 commit 2641e2e

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/loader/Loader.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ Phaser.Loader.prototype = {
617617
*
618618
* @method Phaser.Loader#audio
619619
* @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.
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)

src/sound/AudioSprite.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,9 @@ Phaser.AudioSprite = function (game, key) {
5757
{
5858
var marker = this.config.spritemap[k];
5959
var sound = this.game.add.sound(this.key);
60-
61-
if (marker.loop)
62-
{
63-
sound.addMarker(k, marker.start, (marker.end - marker.start), null, true);
64-
}
65-
else
66-
{
67-
sound.addMarker(k, marker.start, (marker.end - marker.start), null, false);
68-
}
69-
60+
61+
sound.addMarker(k, marker.start, (marker.end - marker.start), null, marker.loop);
62+
7063
this.sounds[k] = sound;
7164
}
7265

0 commit comments

Comments
 (0)