jquery - adding a next button onto jplayer -
i'm trying add next button on jplayer. try using click function didn't work.
the way player setup it's using ajax it's songs , information songs. when song ends song using ajax also. thing trying adding next button don't know how to. ideas?
$(document).ready(function () { $("#jquery_jplayer_1").jplayer({ ready: function () { var data = $.ajax({ url: "getsong.php", async: false }).responsetext; var string = data.split('|'); $(this).jplayer("setmedia", { mp3: string[0] }).jplayer("play"); $('#artist').html(string[1]); $('#songname').html(string[2]); $('#album').html("<img src='" + string[3] + "' width='250' height='250' />"); }, ended: function (event) { var data = $.ajax({ url: "getsong.php", async: false }).responsetext; var string = data.split('|'); $(this).jplayer("setmedia", { mp3: string[0] }).jplayer("play"); $('#artist').html(string[1]); $('#songname').html(string[2]); $('#album').html("<img src='" + string[3] + "' width='250' height='250' />"); }, swfpath: "js", supplied: "mp3" }); });
as said when 1 song ends code fetch next song. in rough way can create button on own , define click
event on , when click, should trigger ended
event of jplayer.
for example:
<input type='button' id='next-song' />
script:
$('#next-song').click(function(){ $("#jquery_jplayer_1").trigger($.jplayer.event.ended); })
you can see documentation have use playlist add-on. have list of songs in playlist , can perform next()
, previous()
, other opertion on playlist
.
Comments
Post a Comment