output XML with PHP (here loaded by Flash)

using something like this in Flash AS perhaps?

playlist.load(“http://www.site.com/playlist.xml”);

wish it were this instead?

playlist.load(“http://www.site.com/playlist.php”);

instead of something like this in xml thus that must be updated…:

<songs><song file=’http://www.site.com/songs/1.mp3′  />
<song file=’http://www.site.com/songs/2.mp3′ /></songs>

you could have something like this, that updates the output xml file each time a new file is added to the songs directory:

< ? p h p

header(‘Content-type:text/xml; charset=utf-8’);
echo “<songs>”;

if ($handle = opendir(‘../songs’)) {
while (false !== ($file = readdir($handle))) {
if ($file != “.” && $file != “..”) {
//echo “$file\n”;
$file_no_extension = implode(‘.’, explode(‘.’, $file, -1));
echo “<song name=’ ” . $file_no_extension . ” ‘ file=’http://www.site.com/songs/” . $file . “‘ />”;
}
}
closedir($handle);
}

echo “</songs>”;
? >

Leave a Reply

You must be logged in to post a comment.