Added ability for full Audio tag playback and iOS touch lock load support.

This commit is contained in:
Richard Davey
2013-07-16 23:32:47 +01:00
parent 72eb22128f
commit a2c756e37f
11 changed files with 620 additions and 215 deletions
+24 -7
View File
@@ -330,6 +330,8 @@ module Phaser {
case 'audio':
file.url = this.getAudioURL(file.url);
console.log('Loader audio');
console.log(file.url);
if (file.url !== null)
{
@@ -344,13 +346,27 @@ module Phaser {
}
else if (this._game.sound.usingAudioTag)
{
file.data = new Audio();
file.data.name = file.key;
file.data.onerror = () => this.fileError(file.key);
file.data.preload = 'auto';
file.data.src = file.url;
file.data.addEventListener('canplaythrough', () => this.fileComplete(file.key), false);
file.data.load();
if (this._game.sound.touchLocked)
{
// If audio is locked we can't do this yet, so need to queue this load request somehow. Bum.
console.log('Audio is touch locked');
file.data = new Audio();
file.data.name = file.key;
file.data.preload = 'auto';
file.data.src = file.url;
this.fileComplete(file.key);
}
else
{
console.log('Audio not touch locked');
file.data = new Audio();
file.data.name = file.key;
file.data.onerror = () => this.fileError(file.key);
file.data.preload = 'auto';
file.data.src = file.url;
file.data.addEventListener('canplaythrough', () => this.fileComplete(file.key), false);
file.data.load();
}
}
}
@@ -379,6 +395,7 @@ module Phaser {
if (this._game.device.canPlayAudio(extension))
{
console.log('getAudioURL', urls[i]);
console.log(urls[i]);
return urls[i];
}