Search the Community
Showing results for tags 'sound audio'.
-
else { this._soundSource = BABYLON.Engine.audioEngine.audioContext.createBufferSource(); this._soundSource.buffer = this._audioBuffer; this._soundSource.connect(this._inputAudioNode); this._soundSource.loop = this.loop; this._soundSource.playbackRate.value = this._playbackRate; this._soundSource.onended = function () { _this._onended(); };//called later... step 2, this._soundSource.start(startTime, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : 0); } this._startTime = startTime; this.isPlaying = true; //called first. step 1, this.isPaused = false; } catch (ex) { BABYLON.Tools.Error("Error while trying to play audio: " + this.name + ", " + ex.message); } } }; Sound.prototype._onended = function () { this.isPlaying = false; //called later... step 2. if (this.onended) { this.onended(); } }; look at the comment. when code is: sound.stop(); sound.play(); the sound.isPlaying sometimes will be set as false.