Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/buffer-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ function createBufferSource (src, opt) {
return duration
}
},
currentTime: {
enumerable: true, configurable: true,
get: function () {
if (!playing)
return audioCurrentTime
else
return audioCurrentTime + (rightNow() - audioStartTime) / 1000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess buffer source time is better be based on audioContext.currentTime than "browser time"

},
set: function (n) {
if(typeof n !== 'number' || n > duration) {
throw new Error('invalid set currentTime = ' + n + ' for audio with duration = ' + duration);
}
if (playing) {
emitter.pause()
audioCurrentTime = n
emitter.play()
}
else {
audioCurrentTime = n
}
}
},
playing: {
enumerable: true, configurable: true,
get: function () {
Expand Down