This will help anyone with JWPLAYER to make a playlist by scanning a folder and creating the correct XML file automatically.
I would like to add one function which I can not work out.
I would like to order the play list by name or date.
$folder = opendir($path);
$start="<asx version='3.0'>n<title>Example ASX playlist</title>";
$Fnm = "./playlist.xml";
$inF = fopen($Fnm,"w");
fwrite($inF,$start."n");
while( $file = readdir($folder) ) {
if (($file != '.')&&($file != '..')&&($file != 'index.htm')){
$result="<entry>n<title>$file</title>n<ref href='$path2$file'/>n<param name='image' value='preview.jpg'/>n</entry>n";
fwrite($inF,$result);
}
}
fwrite($inF,"</asx>");
closedir($folder);
fclose($inF);
?>
Question:
I would like to add to the above code a sort function by date before creating the XML and list.
Thanks
You have to loop the directory and get the date with filemtime and dump it in an array, here’s a working script, you may change $path,$xmlfile or arsort() to sort() depanding on your needs …