How to force play from the start of the track, jPlayer("play", 0) when the browser uses the HTML5 solution

163 views
Skip to first unread message

Frog Pets

unread,
Feb 23, 2012, 7:23:47 PM2/23/12
to jPlayer: HTML5 Audio & Video for jQuery
I'm using the play method to force the track to start immediately
after the player is instanced

$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: "song.mp3"
}).jPlayer("play", 0);

According to the documentation: http://www.jplayer.org/latest/developer-guide/#jPlayer-play

"If issued immediately after a setMedia command, with the time
parameter, and when the browser is using the HTML5 solution, this
command will initially fail and an internal timeout is setup to retry
the command every 100ms until it succeeds"

However when using IE9 (IE7, 8 use the flash solution) which uses the
HTML5 solution, after the player has been instanced the song does not
automatically begin. The internal timeout retrying every 100ms has
not succeed.

How would you recommend I force the play from the start of the track
when the browser uses the HTML5 solution?

Would you recommend forcing IE9 to use the flash fallback? If so, how
would I go about doing that?

Mark Panaghiston

unread,
Feb 24, 2012, 6:14:56 AM2/24/12
to jpl...@googlegroups.com
All you need is a jPlayer("play") there. The time zero param could actually cause a stutter as it is redundant there... Media plays from the beginning the first time. It is only when you are half way through a track that using the jPlayer("play",0) makes sense to return the play head to the start and play from there.

As for your IE9 problems... I expect that your MIME types are wrong on the server for your media. Usually the .mp3 extension is setup on the server, but maybe yours is not for some reason. See this part of the docs for info on your server's MIME types:
http://jplayer.org/latest/developer-guide/#jPlayer-server-response

Frog Pets

unread,
Feb 24, 2012, 7:25:25 PM2/24/12
to jPlayer: HTML5 Audio & Video for jQuery
Thanks so much Mark. After using jPlayer("play") it worked in IE9!

On Feb 24, 3:14 am, Mark Panaghiston <mark.panaghis...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages