I am using this jPlayer plugin to have an audio player on my website.
Trying to get a function, assigned to a button, which rewinds the audio playback 15 seconds back from its current time position and continues to play.
Something similar to the button in the iPhone iTunes podcast player.
There is the code in this fiddle
Essentially the code that I tried to run in the script area is the following.
$(".rewind").click(function(){
$("#jquery_jplayer_1").jPlayer("play", event.jPlayer.status.currentTime - 15);
});
The issue is that event.jPlayer.status.currentTime
is usually accessed when an event is raised by a jPlayer
action. There are a couple work arounds to your problem, but the easiest might be just accessing the jPlayer data
directly, as:
var currentTime = $('#jquery_jplayer_1').data('jPlayer').status.currentTime;
Your updated code might look like this:
$(".rewind").click(function(e){
var currentTime = $('#jquery_jplayer_1').data('jPlayer').status.currentTime;
if (currentTime > 15) {
$("#jquery_jplayer_1").jPlayer("play", currentTime - 15);
}
});
Updated Fiddle: http://jsfiddle.net/XLNCY/18423/