Skip to content

Commit

Permalink
add method setCurrentTime (#1046)
Browse files Browse the repository at this point in the history
* add method setCurrentTime
  • Loading branch information
entonbiba authored and mspae committed Aug 19, 2017
1 parent 3a78d5b commit 8efee7f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/wavesurfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,20 @@ export default class WaveSurfer extends util.Observer {
return this.backend.getCurrentTime();
}

/**
* Set the current play time in seconds.
*
* @param {Number} seconds A positive number in seconds. E.g. 10 means 10
* seconds, 60 means 1 minute
*/
setCurrentTime(seconds) {
if (this.getDuration() >= seconds) {
this.seekTo(1);
} else {
this.seekTo(seconds/this.getDuration());
}
}

/**
* Starts playback from the current position. Optional start and end
* measured in seconds can be used to set the range of audio to play.
Expand Down

0 comments on commit 8efee7f

Please sign in to comment.