Added properties for keeping track of the loading progress

This commit is contained in:
Pavle Goloskokovic 2018-01-08 17:25:42 +01:00
parent 881d37080b
commit 2c89e628c8

View file

@ -40,6 +40,13 @@ var HTML5AudioFile = new Class({
var audio = event.target;
audio.removeEventListener('canplaythrough', this.onProgress);
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
@ -51,6 +58,10 @@ var HTML5AudioFile = new Class({
var instances = (this.config && this.config.instances) || 1;
this.filesTotal = instances;
this.filesLoaded = 0;
this.percentComplete = 0;
for(var i = 0; i < instances; i++)
{
var audio = new Audio();