Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add methods setCurrentTime #1046

Merged
merged 9 commits into from
Apr 18, 2017
24 changes: 20 additions & 4 deletions src/wavesurfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ var WaveSurfer = {
return this.backend.getDuration();
},

getCurrentTime: function () {
return this.backend.getCurrentTime();
},

play: function (start, end) {
this.fireEvent('interaction', this.play.bind(this, start, end));
this.backend.play(start, end);
Expand Down Expand Up @@ -238,6 +234,26 @@ var WaveSurfer = {
return this.backend.getVolume();
},

/**
* Get the current play time.
*/
getCurrentTime: function () {
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: function (seconds) {
if(this.getDuration() >= seconds) {
this.seekTo(1);
} else {
this.seekTo(seconds/this.getDuration());
}
},

/**
* Set the playback rate.
*
Expand Down