Skip to content

Commit c32776b

Browse files
committed
Issue cocos2d#3501: fixed a bug of WebAudioEngine that it don't add sfx object to _effects when the audio didn't preload.
1 parent e6f9c8f commit c32776b

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

AUTHORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Ze Wang @WanderWang Fix crash when BrowserTypes match nothing fr
9494
CCScale9Sprite bug fix
9595
sys.localStorage bug fix
9696
CCArmature refactoring
97+
cc.SpriteFrame and cc.SpriteFrameCache refactoring
9798

9899
Christian Schwartz @cschwartz SpriteFrame.initWithTextureFilename converted fix
99100

cocos2d/audio/SimpleAudioEngine.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,19 +1601,22 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
16011601
audioID = this._audioID++;
16021602
this._audioIDList[audioID] = addSFX;
16031603
return audioID;
1604-
16051604
} else if (this.isFormatSupported(extName) && !(keyName in this._audiosLoading)) {
16061605
// load now only if the type is supported and it is not being loaded currently
16071606
this._audiosLoading[keyName] = true;
16081607
var engine = this;
1609-
16101608
audioID = this._audioID++;
16111609
this._audioIDList[audioID] = null;
16121610
this._fetchData(path, function(buffer) {
16131611
// resource fetched, save it and call playEffect() again, this time it should be alright
16141612
engine._audioData[keyName] = buffer;
16151613
delete engine._audiosLoading[keyName];
1616-
engine._audioIDList[audioID] = engine._beginSound(keyName, loop, engine.getEffectsVolume());
1614+
var asynSFX = engine._beginSound(keyName, loop, engine.getEffectsVolume());
1615+
engine._audioIDList[audioID] = asynSFX;
1616+
var locEffects = engine._effects;
1617+
if (!(keyName in locEffects))
1618+
locEffects[keyName] = [];
1619+
locEffects[keyName].push(asynSFX);
16171620
}, function() {
16181621
// resource fetching failed, doing nothing here
16191622
delete engine._audiosLoading[keyName];

0 commit comments

Comments
 (0)