cocos2d-js
cocos2d-js copied to clipboard
Effect Sound auto plays old paths
On Web, i play game and then i change to other tab and final back to game tab. The effect sound bug occurs, it plays old paths again. This bug just had in version 3.3 and 3.5.
I have the same problem.
Please try v3.6, @VisualSJ should have fixed the issue
Hi @pandamicro , the problem still occurs in v3.6
@letrungtrung What browser appeared this problem? what is the browser version?
I use firefox 36, Didn't recreate the problem... I will continue to try it. Thanks ^.^
hi @VisualSJ I'm testing on firefox v38.0.1 and chrome v42.0.2311.152 . Both browsers occurred that problem.
After doing some checking I discovered the reason that caused the error is in _resumeOfWebAudio (CCAudio.js). And this is my solution:
_resumeOfWebAudio: function () {
var audio = this._currentSource;
if (audio) {
this._startTime = this._context.currentTime;
// === Start my code
var numOfPlayed = Math.floor(this._currentTime / audio.buffer.duration);
if ((this.loop && numOfPlayed >= this.loop) || (!this.loop && numOfPlayed !== 0)) {
this._stopOfWebAudio();
return;
}
if (this.loop)
this.loop -= numOfPlayed;
//=== End my code
var offset = this._currentTime % audio.buffer.duration;
this._playOfWebAudio(offset);
}
}
This is only a temporary solution while waiting for the official fixing!