$(function(){ var playItem = 0; var myPlayList = [ {name:"She moved in (Popular damage RMX)",mp3:"play/She moved in (Popular damage RMX).mp3"}, {name:"She moved in (Robot Koch RMX)",mp3:"play/She moved in (Robot Koch RMX).mp3"}, {name:"She moved in (Timid Tiger Remix)",mp3:"play/She moved in (Timid Tiger Remix).mp3"}, {name:"She moved in (Dead Rabbit RMX)",mp3:"play/She moved in (Dead Rabbit RMX).mp3"}, {name:"Since She moved in (NIYI RMX)",mp3:"play/Since She moved in (NIYI RMX).mp3"}, ]; $("#jquery_jplayer").jPlayer({ ready: function() { playListInit(false); // Parameter is a boolean for autoplay. } }) .jPlayerId("play", "player_play") .jPlayerId("pause", "player_pause") .jPlayerId("stop", "player_stop") .jPlayerId("loadBar", "player_progress_load_bar") .jPlayerId("playBar", "player_progress_play_bar") .onProgressChange(function(){ return true; }) .onSoundComplete( function() { playListNext(); }); $("#ctrl_prev").click( function() { playListPrev(); return false; }); $("#ctrl_next").click( function() { playListNext(); return false; }); function playListInit(autoplay) { if(autoplay) { playListChange( playItem ); } else { playListConfig( playItem ); } } function playListConfig( index ) { var title = myPlayList[index].name; $('#songname').text(title); $("#playlist_item_"+playItem).removeClass("playlist_current"); $("#playlist_item_"+index).addClass("playlist_current"); playItem = index; $("#jquery_jplayer").setFile(myPlayList[playItem].mp3); } function playListChange( index ) { playListConfig( index ); $("#jquery_jplayer").play(); } function playListNext() { var index = (playItem+1 < myPlayList.length) ? playItem+1 : 0; playListChange( index ); } function playListPrev() { var index = (playItem-1 >= 0) ? playItem-1 : myPlayList.length-1; playListChange( index ); } });