From ecabc9fd03e1fbecca682ab281cf19f996c381ee Mon Sep 17 00:00:00 2001 From: Jer Noble Date: Fri, 28 Mar 2014 15:05:49 -0700 Subject: [PATCH 1/1] Add timeupdate support. --- sound.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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() { -- 2.40.1