@@ -59,42 +59,45 @@ var AudioFile = new Class({
5959
6060} ) ;
6161
62- // When registering a factory function 'this' refers to the Loader context.
63- //
64- // There are several properties available to use:
65- //
66- // this.scene - a reference to the Scene that owns the GameObjectFactory
67-
68- FileTypesManager . register ( 'audio' , function ( key , urls , config , xhrSettings )
62+ AudioFile . create = function ( loader , key , urls , config , xhrSettings )
6963{
70- var game = this . systems . game ;
64+ var game = loader . systems . game ;
7165 var audioConfig = game . config . audio ;
7266 var deviceAudio = game . device . Audio ;
7367
7468 if ( ( audioConfig && audioConfig . noAudio ) || ( ! deviceAudio . webAudio && ! deviceAudio . audioData ) )
7569 {
7670 console . info ( 'Skipping loading audio \'' + key + '\' since sounds are disabled.' ) ;
77- return this ;
71+ return null ;
7872 }
7973
8074 var url = AudioFile . findAudioURL ( game , urls ) ;
8175
8276 if ( ! url )
8377 {
8478 console . warn ( 'No supported url provided for audio \'' + key + '\'!' ) ;
85- return this ;
79+ return null ;
8680 }
8781
88- var audioFile ;
89-
9082 if ( deviceAudio . webAudio && ! ( audioConfig && audioConfig . disableWebAudio ) )
9183 {
92- audioFile = new AudioFile ( key , url , this . path , xhrSettings , game . sound . context ) ;
84+ return new AudioFile ( key , url , this . path , xhrSettings , game . sound . context ) ;
9385 }
9486 else
9587 {
96- audioFile = new HTML5AudioFile ( key , url , this . path , config ) ;
88+ return new HTML5AudioFile ( key , url , this . path , config ) ;
9789 }
90+ } ;
91+
92+ // When registering a factory function 'this' refers to the Loader context.
93+ //
94+ // There are several properties available to use:
95+ //
96+ // this.scene - a reference to the Scene that owns the GameObjectFactory
97+
98+ FileTypesManager . register ( 'audio' , function ( key , urls , config , xhrSettings )
99+ {
100+ var audioFile = AudioFile . create ( this , key , urls , config , xhrSettings ) ;
98101
99102 if ( audioFile )
100103 {
0 commit comments