X-Git-Url: http://id.pley.net/sound.git/blobdiff_plain/2acf7355303ecf1cb8c61823ee72bc60c8c01284..ecabc9fd03e1fbecca682ab281cf19f996c381ee:/sound.js 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() {