From: Jer Noble Date: Fri, 28 Mar 2014 16:52:42 +0000 (-0700) Subject: Fix restarting at current time after pause. X-Git-Url: http://105106.c2e0p.group/sound.git/commitdiff_plain/96498ce8e0ac1fb6908a87e43f9c8a6c88157e76 Fix restarting at current time after pause. --- diff --git a/sound.js b/sound.js index 2303927..c8ee706 100644 --- a/sound.js +++ b/sound.js @@ -216,6 +216,8 @@ Sound.prototype = { this.gainNode.gain.value = this._muted ? 0 : this._volume; this.gainNode.connect(Sound.audioContext.destination); + this.startTime = Sound.audioContext.currentTime; + this.node = Sound.audioContext.createBufferSource(); this.node.connect(this.gainNode); this.node.buffer = this.buffer; @@ -364,7 +366,7 @@ Sound.prototype = { getCurrentTime: function() { if (!this.node) return this.nextStartTime; - return this.nextStartTime + Sound.audioContext.currentTIme - this.startTime; + return this.nextStartTime + Sound.audioContext.currentTime - this.startTime; }, setCurrentTime: function(time) {