mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
Added properties for keeping track of the loading progress
This commit is contained in:
parent
881d37080b
commit
2c89e628c8
1 changed files with 11 additions and 0 deletions
|
@ -40,6 +40,13 @@ var HTML5AudioFile = new Class({
|
||||||
var audio = event.target;
|
var audio = event.target;
|
||||||
audio.removeEventListener('canplaythrough', this.onProgress);
|
audio.removeEventListener('canplaythrough', this.onProgress);
|
||||||
audio.removeEventListener('error', this.onError);
|
audio.removeEventListener('error', this.onError);
|
||||||
|
|
||||||
|
if(this.filesLoaded++ === this.filesTotal)
|
||||||
|
{
|
||||||
|
this.onLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.percentComplete = Math.min((this.filesLoaded / this.filesTotal), 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Called by the Loader, starts the actual file downloading
|
// Called by the Loader, starts the actual file downloading
|
||||||
|
@ -51,6 +58,10 @@ var HTML5AudioFile = new Class({
|
||||||
|
|
||||||
var instances = (this.config && this.config.instances) || 1;
|
var instances = (this.config && this.config.instances) || 1;
|
||||||
|
|
||||||
|
this.filesTotal = instances;
|
||||||
|
this.filesLoaded = 0;
|
||||||
|
this.percentComplete = 0;
|
||||||
|
|
||||||
for(var i = 0; i < instances; i++)
|
for(var i = 0; i < instances; i++)
|
||||||
{
|
{
|
||||||
var audio = new Audio();
|
var audio = new Audio();
|
||||||
|
|
Loading…
Reference in a new issue