Below is the code which plays an mp3 audio file.I can play only one file but i need multiple files to be played, i mean like an playlist.So,kindly help me out.Ita an jplayer.
thank you
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: "media/test.mp3",
}).jPlayer("play"); // auto play
},
ended: function (event) {
$(this).jPlayer("play");
},
swfPath: "swf",
supplied: "mp3"
})
.bind($.jPlayer.event.play, function() { // pause other instances of player when current one play
$(this).jPlayer("pauseOthers");
});
Hey you can do the following.
I instantiate the player on page load:
jQuery("#jquery_jplayer_1").jPlayer({
swfPath: "http://www.jplayer.org/latest/js/Jplayer.swf",
supplied: "mp3",
wmode: "window",
preload:"auto",
autoPlay: true,
errorAlerts:false,
warningAlerts:false
});
Then inside a listener, which will be unique for every item, you need to: A) Fetch track name/URL, I guess you should be able to figure this out.
B) Pass the track to the setMedia
jQuery("#jquery_jplayer_1").jPlayer("setMedia", {
mp3: "http:xxxx.rackcdn.com/"+track+".MP3"
});
C) Play the track
jQuery("#jquery_jplayer_1").jPlayer("play");
To get the track Id you need to install listeners on your playable items(maybe a a playable class?) and get the track from that one.