Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ When a MediaElement is used as the source, other options will be passed to [simp

> :warning: For accurate `loopStart` and `loopEnd` results, you should use a buffer source. MediaElement sources fall back to using a requestAnimationFrame timer, which is less robust, especially when the tab is out of view.

#### `player.play()`
#### `player.play([seek])`

Plays the audio, resuming it from a paused state.
Plays the audio, resuming it from a paused state (with an optional seek parameter to adjust currentTime).

#### `player.pause()`

Expand Down Expand Up @@ -162,6 +162,10 @@ A read-only boolean to determine whether the audio node is currently playing.

A getter/setter for the `player.node.gain` value, which allows you to adjust the volume during playback.

#### `player.currentTime`

A getter/setter for the `audio.currentTime` value, which allows you to seek.

### events

#### `player.on('load', fn)`
Expand Down
8 changes: 7 additions & 1 deletion lib/media-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ function createMediaSource (src, opt) {
emitter.context = audioContext
emitter.node = node
emitter.pause = audio.pause.bind(audio)
emitter.play = function () {
emitter.play = function (seek) {
if (opt.autoResume !== false) resume(emitter.context)
if (typeof seek !== 'undefined') {
audio.currentTime = seek
}
return audio.play()
}

Expand Down Expand Up @@ -102,6 +105,9 @@ function createMediaSource (src, opt) {
enumerable: true, configurable: true,
get: function () {
return audio.currentTime
},
set: function(value) {
audio.currentTime = value
}
},
playing: {
Expand Down