@@ -15,6 +15,8 @@ var HTML5AudioFile = new Class({
1515 {
1616 this . locked = locked ;
1717
18+ this . loaded = false ;
19+
1820 var fileConfig = {
1921 type : 'audio' ,
2022 extension : GetFastValue ( url , 'type' , '' ) ,
@@ -29,7 +31,14 @@ var HTML5AudioFile = new Class({
2931
3032 onLoad : function ( )
3133 {
32- this . callback ( this , true ) ;
34+ if ( this . loaded )
35+ {
36+ return ;
37+ }
38+
39+ this . loaded = true ;
40+
41+ this . loader . nextFile ( this , true ) ;
3342 } ,
3443
3544 onError : function ( event )
@@ -41,7 +50,7 @@ var HTML5AudioFile = new Class({
4150 audio . onerror = null ;
4251 }
4352
44- this . callback ( this , false ) ;
53+ this . loader . nextFile ( this , false ) ;
4554 } ,
4655
4756 onProgress : function ( event )
@@ -50,18 +59,22 @@ var HTML5AudioFile = new Class({
5059 audio . oncanplaythrough = null ;
5160 audio . onerror = null ;
5261
53- if ( ++ this . filesLoaded === this . filesTotal )
62+ this . filesLoaded ++ ;
63+
64+ this . percentComplete = Math . min ( ( this . filesLoaded / this . filesTotal ) , 1 ) ;
65+
66+ this . loader . emit ( 'fileprogress' , this , this . percentComplete ) ;
67+
68+ if ( this . filesLoaded === this . filesTotal )
5469 {
5570 this . onLoad ( ) ;
5671 }
57-
58- this . percentComplete = Math . min ( ( this . filesLoaded / this . filesTotal ) , 1 ) ;
5972 } ,
6073
6174 // Called by the Loader, starts the actual file downloading
62- load : function ( callback , baseURL )
75+ load : function ( loader )
6376 {
64- this . callback = callback ;
77+ this . loader = loader ;
6578
6679 this . data = [ ] ;
6780
@@ -90,7 +103,7 @@ var HTML5AudioFile = new Class({
90103 for ( i = 0 ; i < this . data . length ; i ++ )
91104 {
92105 audio = this . data [ i ] ;
93- audio . src = GetURL ( this , baseURL || '' ) ;
106+ audio . src = GetURL ( this , loader . baseURL ) ;
94107
95108 if ( ! this . locked )
96109 {
@@ -100,13 +113,7 @@ var HTML5AudioFile = new Class({
100113
101114 if ( this . locked )
102115 {
103- setTimeout ( function ( )
104- {
105- this . filesLoaded = this . filesTotal ;
106- this . percentComplete = 1 ;
107- this . onLoad ( ) ;
108-
109- } . bind ( this ) ) ;
116+ setTimeout ( this . onLoad . bind ( this ) ) ;
110117 }
111118 }
112119
0 commit comments