HOw to add playlist to jplayer

Below is the code that plays the mp3 file. I can only play one file, but I need multiple files to play, I mean like a playlist. So please help me out. This is 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");
});

      

+3


source to share


2 answers


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 that will be unique for each element, you need to: A) Get the track name / url, I think you should understand this.

B) Pass track to setMedia



jQuery("#jquery_jplayer_1").jPlayer("setMedia", {
  mp3: "http:xxxx.rackcdn.com/"+track+".MP3"
});

      

C) Track Play

jQuery("#jquery_jplayer_1").jPlayer("play");

      

To get the track id, you need to set listeners to playable items (perhaps a class that can be played?) And get a track from that.

-1


source


Please see the jPlayer Jukebox add-on . It is based on the jPlayer playlist add- on but adds additional features like the ability to crawl the page for media links and play them.



jPlayer Jukebox add-on

-2


source







All Articles