$(document).ready(function(){ var playItem = 0; var myPlayList = [ {name:"Rise & Fall",mp3:"/media/195027/rise&fall.mp3",artist:"Daniel Renstrom",album:"On The Incarnation",buynowlink:"http://danielrenstrom.storenvy.com/"}, {name:"Let Us Love and Sing and Wonder",mp3:"/media/194850/02 let us love and sing and wonder 2.mp3",artist:"Daniel Renstrom",album:"Adore and Tremble",buynowlink:"http://danielrenstrom.storenvy.com/products"}, {name:"At the Cross",mp3:"/media/194711/atthecross.mp3",artist:"Daniel Renstrom",album:"Adore and Tremble",buynowlink:"http://www.itunes.com"}, {name:"Comfort Ye",mp3:"/media/195007/comfortye.mp3",artist:"Daniel Renstrom",album:"On The Incarnation",buynowlink:"http://danielrenstrom.storenvy.com/"}, {name:"Where Would I Go",mp3:"/media/195039/wherewouldigo.mp3",artist:"Daniel Renstrom",album:"Adore and Tremble",buynowlink:"http://danielrenstrom.storenvy.com/"}, ]; // Local copy of jQuery selectors, for performance. var jpPlayTime = $("#jplayer_play_time"); var jpTotalTime = $("#jplayer_total_time"); $("#jquery_jplayer").jPlayer({ ready: function() { displayPlayList(); playListInit(false); // Parameter is a boolean for autoplay. }, nativeSupport: false, swfPath: "/js" }) .jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) { jpPlayTime.text($.jPlayer.convertTime(playedTime)); jpTotalTime.text($.jPlayer.convertTime(totalTime)); }) .jPlayer("onSoundComplete", function() { playListNext(); }); $("#jplayer_previous").click( function() { playListPrev(); $(this).blur(); return false; }); $("#jplayer_next").click( function() { playListNext(); $(this).blur(); return false; }); function displayPlayList() { $("#jplayer_playlist ul").empty(); for (i=0; i < myPlayList.length; i++) { var listItem = (i == myPlayList.length-1) ? "
  • " : "
  • "; listItem += "" + myPlayList[i].name + "" + myPlayList[i].album + " by " + myPlayList[i].artist + " Buy Now
  • "; $("#jplayer_playlist ul").append(listItem); $("#jplayer_playlist_item_"+i).data( "index", i ).click( function() { var index = $(this).data("index"); if (playItem != index) { playListChange( index ); } else { $("#jquery_jplayer").jPlayer("play"); } $(this).blur(); return false; }); } } function playListInit(autoplay) { if(autoplay) { playListChange( playItem ); } else { playListConfig( playItem ); } } function playListConfig( index ) { $("#jplayer_playlist_item_"+playItem).removeClass("jplayer_playlist_current").parent().removeClass("jplayer_playlist_current"); $("#jplayer_playlist_item_"+index).addClass("jplayer_playlist_current").parent().addClass("jplayer_playlist_current"); playItem = index; $("#jquery_jplayer").jPlayer("setFile", myPlayList[playItem].mp3); } function playListChange( index ) { playListConfig( index ); $("#jquery_jplayer").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 ); } });