@@ -123,17 +123,21 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
123
123
/**
124
124
* Preload music resource.
125
125
* @param {String } path
126
+ * @param {Function } selector
127
+ * @param {Object } target
126
128
*/
127
- preloadMusic :function ( path ) {
128
- this . preloadSound ( path ) ;
129
+ preloadMusic :function ( path , selector , target ) {
130
+ this . preloadSound ( path , selector , target ) ;
129
131
} ,
130
132
131
133
/**
132
134
* Preload effect resource.
133
135
* @param {String } path
136
+ * @param {Function } selector
137
+ * @param {Object } target
134
138
*/
135
- preloadEffect :function ( path ) {
136
- this . preloadSound ( path ) ;
139
+ preloadEffect :function ( path , selector , target ) {
140
+ this . preloadSound ( path , selector , target ) ;
137
141
} ,
138
142
139
143
/**
@@ -221,8 +225,10 @@ cc.SimpleAudioEngine = cc.AudioEngine.extend(/** @lends cc.SimpleAudioEngine# */
221
225
* Preload music resource.<br />
222
226
* This method is called when cc.Loader preload resources.
223
227
* @param {String } path The path of the music file with filename extension.
228
+ * @param {Function } selector
229
+ * @param {Object } target
224
230
*/
225
- preloadSound :function ( path ) {
231
+ preloadSound :function ( path , selector , target ) {
226
232
if ( this . _soundSupported ) {
227
233
var realPath = this . _resPath + path ;
228
234
var extName = this . _getExtFromFullPath ( path ) ;
@@ -234,12 +240,12 @@ cc.SimpleAudioEngine = cc.AudioEngine.extend(/** @lends cc.SimpleAudioEngine# */
234
240
sfxCache . audio = new Audio ( realPath ) ;
235
241
sfxCache . audio . preload = 'auto' ;
236
242
var soundPreloadCanplayHandler = function ( ) {
237
- cc . Loader . getInstance ( ) . onResLoaded ( ) ;
243
+ cc . doCallback ( selector , target ) ;
238
244
this . removeEventListener ( 'canplaythrough' , soundPreloadCanplayHandler , false ) ;
239
245
this . removeEventListener ( 'error' , soundPreloadErrorHandler , false ) ;
240
246
} ;
241
247
var soundPreloadErrorHandler = function ( e ) {
242
- cc . Loader . getInstance ( ) . onResLoadingErr ( e . srcElement . src ) ;
248
+ cc . doCallback ( selector , target , e . srcElement . src ) ;
243
249
this . removeEventListener ( 'canplaythrough' , soundPreloadCanplayHandler , false ) ;
244
250
this . removeEventListener ( 'error' , soundPreloadErrorHandler , false ) ;
245
251
} ;
@@ -252,7 +258,7 @@ cc.SimpleAudioEngine = cc.AudioEngine.extend(/** @lends cc.SimpleAudioEngine# */
252
258
}
253
259
}
254
260
}
255
- cc . Loader . getInstance ( ) . onResLoaded ( ) ;
261
+ cc . doCallback ( selector , target ) ;
256
262
} ,
257
263
258
264
/**
@@ -1309,8 +1315,10 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
1309
1315
* Preload music resource.<br />
1310
1316
* This method is called when cc.Loader preload resources.
1311
1317
* @param {String } path The path of the music file with filename extension.
1318
+ * @param {Function } selector
1319
+ * @param {Object } target
1312
1320
*/
1313
- preloadSound : function ( path ) {
1321
+ preloadSound : function ( path , selector , target ) {
1314
1322
if ( ! this . _soundSupported )
1315
1323
return ;
1316
1324
@@ -1319,7 +1327,7 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
1319
1327
1320
1328
// not supported, already loaded, already loading
1321
1329
if ( this . _audioData [ keyName ] || this . _audiosLoading [ keyName ] || ! this . isFormatSupported ( extName ) ) {
1322
- cc . Loader . getInstance ( ) . onResLoaded ( ) ;
1330
+ cc . doCallback ( selector , target ) ;
1323
1331
return ;
1324
1332
}
1325
1333
@@ -1329,11 +1337,11 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
1329
1337
// resource fetched, in @param buffer
1330
1338
engine . _audioData [ keyName ] = buffer ;
1331
1339
delete engine . _audiosLoading [ keyName ] ;
1332
- cc . Loader . getInstance ( ) . onResLoaded ( ) ;
1340
+ cc . doCallback ( selector , target ) ;
1333
1341
} , function ( ) {
1334
1342
// resource fetching failed
1335
1343
delete engine . _audiosLoading [ keyName ] ;
1336
- cc . Loader . getInstance ( ) . onResLoadingErr ( path ) ;
1344
+ cc . doCallback ( selector , target , path ) ;
1337
1345
} ) ;
1338
1346
} ,
1339
1347
0 commit comments