Hi, JPlayer supports playlists, but it keeps the playlist in the javascript:
[CODE] var myPlayList = [
{name:”Tempered Song”,mp3:”http://www.miaowmusic.com/mp3/Miaow-01-Tempered-song.mp3″},
{name:”Hidden”,mp3:”http://www.miaowmusic.com/mp3/Miaow-02-Hidden.mp3″},
{name:”Lentement”,mp3:”http://www.miaowmusic.com/mp3/Miaow-03-Lentement.mp3″},
{name:”Lismore”,mp3:”http://www.miaowmusic.com/mp3/Miaow-04-Lismore.mp3″,ogg:”http://www.miaowmusic.com/ogg/Miaow-04-Lismore.ogg”},
{name:”The Separation”,mp3:”http://www.miaowmusic.com/mp3/Miaow-05-The-separation.mp3″,ogg:”http://www.miaowmusic.com/ogg/Miaow-05-The-separation.ogg”},
{name:”Beside Me”,mp3:”http://www.miaowmusic.com/mp3/Miaow-06-Beside-me.mp3″,ogg:”http://www.miaowmusic.com/ogg/Miaow-06-Beside-me.ogg”},
{name:”Bubble”,mp3:”http://www.miaowmusic.com/mp3/Miaow-07-Bubble.mp3″,ogg:”http://www.miaowmusic.com/ogg/Miaow-07-Bubble.ogg”},
{name:”Stirring of a Fool”,mp3:”http://www.miaowmusic.com/mp3/Miaow-08-Stirring-of-a-fool.mp3″,ogg:”http://www.miaowmusic.com/ogg/Miaow-08-Stirring-of-a-fool.ogg”},
{name:”Partir”,mp3:”http://www.miaowmusic.com/mp3/Miaow-09-Partir.mp3″,ogg:”http://www.miaowmusic.com/ogg/Miaow-09-Partir.ogg”},
{name:”Thin Ice”,mp3:”http://www.miaowmusic.com/mp3/Miaow-10-Thin-ice.mp3″,ogg:”http://www.miaowmusic.com/ogg/Miaow-10-Thin-ice.ogg”}
];
I’m trying to read in an xml file into this “myPlayList” array so that I can have an easy way of updating it, but I’m having trouble understanding this array structure.
In the JPlayer code they use “myPlayList[i].name” and “myPlayList[i].mp3″ in a for loop to cycle through the playlist and display the links in a list.
My idea was to get rid of the “myPlayList” var declaration and dynamically populate the array variable from my xml file:
[CODE] var xmlDoc;
var myPlayList = []
if (window.XMLHttpRequest)
{
xmlDoc=new window.XMLHttpRequest();
xmlDoc.open(“GET”,”playlist.xml”,false);
xmlDoc.send(“”);
xmlDoc=xmlDoc.responseXML;
}
// IE 5 and IE 6
else if (ActiveXObject(“Microsoft.XMLDOM”))
{
xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);
xmlDoc.async=false;
xmlDoc.load(“playlist.xml”);
}
x=xmlDoc.getElementsByTagName(“track”);
for (i=0;i<x.length;i++)
{
myPlayList[i].name = x[i].childNodes[0].nodeName;
myPlayList[i].mp3 = x[i].childNodes[1].nodeName;
}
It didn’t display any songs ?
I’m not sure what I’m doing wrong. Please help. Also, I’m guessing this has been done before (although I did a google search and couldn’t find anything), so If you could point me to some resources I’d appreciate it. If there is another simpler option (over xml) I’d like to know.
Thanks.