From: Jer Noble Date: Fri, 28 Mar 2014 22:05:49 +0000 (-0700) Subject: Add timeupdate support. X-Git-Url: http://105106.c2e0p.group/sound.git/commitdiff_plain/ecabc9fd03e1fbecca682ab281cf19f996c381ee Add timeupdate support. --- diff --git a/sound.js b/sound.js index a260153..e195ca6 100644 --- a/sound.js +++ b/sound.js @@ -45,6 +45,7 @@ function Sound(src) { this.selectResourceTimer = null; this.fetchResourceTimer = null; + this.timeUpdateTimer = null; this.buffer = null; this.node = null; @@ -270,8 +271,13 @@ Sound.prototype = { this.node.playbackRate.value = this._playbackRate; this.node.start(0, this.nextStartTime); this.node.onended = this.onended.bind(this); + + this.timeUpdateTimer = setInterval(this.sendTimeUpdate.bind(this), 250); }, + sendTimeUpdate: function() { + this.dispatchEventAsync(new CustomEvent('timeupdate')); + }, pause: function() { if (this._networkState === this.NETWORK.EMPTY) @@ -301,6 +307,8 @@ Sound.prototype = { this.gainNode.disconnect(); delete this.gainNode; } + + clearInterval(this.timeUpdateTimer); }, onended: function() {