Skip to content

Commit aa75caf

Browse files
committed
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-html5 into Iss4051_FixTMXLayerRemoveChild
2 parents b14c26a + 70c4bee commit aa75caf

File tree

6 files changed

+146
-153
lines changed

6 files changed

+146
-153
lines changed

cocos2d/audio/SimpleAudioEngine.js

+20-12
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,21 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
123123
/**
124124
* Preload music resource.
125125
* @param {String} path
126+
* @param {Function} selector
127+
* @param {Object} target
126128
*/
127-
preloadMusic:function(path){
128-
this.preloadSound(path);
129+
preloadMusic:function(path, selector, target){
130+
this.preloadSound(path, selector, target);
129131
},
130132

131133
/**
132134
* Preload effect resource.
133135
* @param {String} path
136+
* @param {Function} selector
137+
* @param {Object} target
134138
*/
135-
preloadEffect:function(path){
136-
this.preloadSound(path);
139+
preloadEffect:function(path, selector, target){
140+
this.preloadSound(path, selector, target);
137141
},
138142

139143
/**
@@ -221,8 +225,10 @@ cc.SimpleAudioEngine = cc.AudioEngine.extend(/** @lends cc.SimpleAudioEngine# */
221225
* Preload music resource.<br />
222226
* This method is called when cc.Loader preload resources.
223227
* @param {String} path The path of the music file with filename extension.
228+
* @param {Function} selector
229+
* @param {Object} target
224230
*/
225-
preloadSound:function (path) {
231+
preloadSound:function (path, selector, target) {
226232
if (this._soundSupported) {
227233
var realPath = this._resPath + path;
228234
var extName = this._getExtFromFullPath(path);
@@ -234,12 +240,12 @@ cc.SimpleAudioEngine = cc.AudioEngine.extend(/** @lends cc.SimpleAudioEngine# */
234240
sfxCache.audio = new Audio(realPath);
235241
sfxCache.audio.preload = 'auto';
236242
var soundPreloadCanplayHandler = function () {
237-
cc.Loader.getInstance().onResLoaded();
243+
cc.doCallback(selector, target);
238244
this.removeEventListener('canplaythrough', soundPreloadCanplayHandler, false);
239245
this.removeEventListener('error', soundPreloadErrorHandler, false);
240246
};
241247
var soundPreloadErrorHandler = function (e) {
242-
cc.Loader.getInstance().onResLoadingErr(e.srcElement.src);
248+
cc.doCallback(selector, target,e.srcElement.src);
243249
this.removeEventListener('canplaythrough', soundPreloadCanplayHandler, false);
244250
this.removeEventListener('error', soundPreloadErrorHandler, false);
245251
};
@@ -252,7 +258,7 @@ cc.SimpleAudioEngine = cc.AudioEngine.extend(/** @lends cc.SimpleAudioEngine# */
252258
}
253259
}
254260
}
255-
cc.Loader.getInstance().onResLoaded();
261+
cc.doCallback(selector, target);
256262
},
257263

258264
/**
@@ -1309,8 +1315,10 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
13091315
* Preload music resource.<br />
13101316
* This method is called when cc.Loader preload resources.
13111317
* @param {String} path The path of the music file with filename extension.
1318+
* @param {Function} selector
1319+
* @param {Object} target
13121320
*/
1313-
preloadSound: function(path) {
1321+
preloadSound: function(path, selector, target) {
13141322
if (!this._soundSupported)
13151323
return;
13161324

@@ -1319,7 +1327,7 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
13191327

13201328
// not supported, already loaded, already loading
13211329
if (this._audioData[keyName] || this._audiosLoading[keyName] || !this.isFormatSupported(extName)) {
1322-
cc.Loader.getInstance().onResLoaded();
1330+
cc.doCallback(selector, target);
13231331
return;
13241332
}
13251333

@@ -1329,11 +1337,11 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
13291337
// resource fetched, in @param buffer
13301338
engine._audioData[keyName] = buffer;
13311339
delete engine._audiosLoading[keyName];
1332-
cc.Loader.getInstance().onResLoaded();
1340+
cc.doCallback(selector, target);
13331341
}, function() {
13341342
// resource fetching failed
13351343
delete engine._audiosLoading[keyName];
1336-
cc.Loader.getInstance().onResLoadingErr(path);
1344+
cc.doCallback(selector, target, path);
13371345
});
13381346
},
13391347

0 commit comments

Comments
 (0)