How to start at certain song on a playlist?

59 views
Skip to first unread message

J. Frank Parnell

unread,
Apr 5, 2011, 9:55:29 PM4/5/11
to jPlayer: HTML5 Audio & Video for jQuery
Lets say I have a player here:
http://beta.radiokdug.com/index.php?page=band&band=24
normally, this page does not autostart. Great.

What would I need to do to get it to autoplay song 3 (and then
continue down the playlist as usual)?
http://beta.radiokdug.com/index.php?page=band&band=24&song=Bow_Hill_-_Next_Exit_-_03_-_Look_My_Way.mp3
I can do whatever php that implies, but I'm looking for the js.

J. Frank Parnell

unread,
Apr 6, 2011, 3:01:47 AM4/6/11
to jPlayer: HTML5 Audio & Video for jQuery


Oh well, that was easy. In the ready function, I just put
$('#jp_playlist_2_item_3').trigger('click');

ready: function () {
audioPlaylist.displayPlaylist();
audioPlaylist.playlistInit(false); // Parameter is a boolean for
autoplay.
$('#jp_playlist_2_item_3').trigger('click');
},


jPlayer will build the <ul> with <li> ids = to something similar to
the above, depending on how many playlists you have on a page, etc.
Maybe someone who knows more can tell about that. At any rate, I
looked at the 'generated source' with FF web dev tool bar, found that
the 'links' jPlayer created look like
<li class="jp-playlist-current">
<a class="jp-playlist-current" href="#" id="jp_playlist_2_item_0"
tabindex="1">Bow Hill - Next Exit - 01 - Sore From</a>
</li>
<li>
<a href="#" id="jp_playlist_2_item_1" tabindex="1">Bow Hill - Next
Exit - 02 - Break the Mold</a>
</li>

Mark Panaghiston

unread,
Apr 6, 2011, 2:37:44 PM4/6/11
to jpl...@googlegroups.com
audioPlaylist.current = 2; would also set the index to point at the 3rd track.

You could then put that line at the start of the ready function. ie., before displaying and init the playlist.

Or if all of the playlists start from the 3rd one, then you could just change the original object property for current.

By the way, the playlist is not actually part of jPlayer. It is a piece of code that uses jPlayer to enable a playlist.

Best regards,
Mark P.

J. Frank Parnell

unread,
Apr 6, 2011, 10:15:43 PM4/6/11
to jPlayer: HTML5 Audio & Video for jQuery
Ah, yes that works, too, but as I have
audioPlaylist.playlistInit(false);
it does not play automatically. Easy fix with php, although I may
leave it that way.

thanks
J

On Apr 6, 11:37 am, Mark Panaghiston <mark.panaghis...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages