Feature Request: $('#jquery_jplayer').playHeadTime(start_offset, end_offset)

43 views
Skip to first unread message

Jonathan of Cambridge

unread,
Feb 18, 2010, 9:12:09 PM2/18/10
to jPlayer: the CSS styleable jQuery audio player plugin
Dear jPlayer,

Congratulations on the release of jPlayer 1.0!

Obviously, I'm currently using the previous release at the moment.

I was wondering whether there is a way using either the previous
release or the new release to request the player to play from an
absolute start offset until an absolute end offset. (The new part
here is to have it pause upon reaching the end offset.)

Please let me know what is the simplest way to accomplish that task.

Thank you and in advance,

Jonathan

Mark P

unread,
Feb 18, 2010, 11:27:40 PM2/18/10
to jPlayer: the CSS styleable jQuery audio player plugin
Hello Jonathan,

The type of functionality you describe is not built into jPlayer
1.0.0, but you can achieve a similar result by checking the playedTime
in the jPlayer("onProgressChange", handlerFunction).
http://www.happyworm.com/jquery/jplayer/latest/developer-guide.htm#jPlayer-onProgressChange

$("#jquery_jplayer").jPlayer("onProgressChange",
function(lp,ppr,ppa,pt,tt) {
if(pt >= end_offset) { // times in milliseconds
this.element.jPlayer("stop");
}
});

You would start the jPlayer using the existing command:
$("#jquery_jplayer").jPlayer("playHeadTime", start_offset);

Bear in mind that setting a file (setFile) and then changing the
playHeadTime immediately afterwards tends to give varying results. The
audio tends to start playing 'round about' the time specified, but
unless the file is downloaded already I can be a little inaccurate.
What with HTML5 browser variations too, where some allow seeking,
while others download from the start. I think the Flash would give the
most stable results, but this is an area that would benefit from some
more testing.

In a future version I am considering adding a .load() method... Which
would allow you to get the download going without doing a
crude .play().pause(). Or rather the more verbose jPlayer 1.0.0 syntax
of .jPlayer("play").jPlayer("pause").

If you were using the graphical demo skins, then the load/play bars
might get a little confused though. You'd have to add the start_offset
logic into the onProgressChange too... But I guess you are not using
the visual progress bars as it does not make much sense to have them.

That is unless we were to implement it into the jPlayer system itself,
where the start/end offsets could be taken into account and the
progress bars respond accordingly, ie., a click on the far left is
equivalent to start_offset and the far right equivalent to end_offset.
I'll consider the feature in a future release.

For the time being, I have logged your feature request on GitHub.
http://github.com/happyworm/jPlayer/issues

Let us know how you get on.
Best regards,
Mark P

Reply all
Reply to author
Forward
0 new messages