I’m constructing an Mp3 player for my site that is fed it’s songlist dynamically through the xml.php. All I need in the script is a way to get the ‘filesize’ and ‘duration’ from the songs, and output them in the XML rendering section of the PHP file.
I was just wondering if it is possible to do this with a few lines of code, rather than implement a whole ID3 class into my script. I don’t yet know enough to rip the classes apart and take the functions that I need out. So if anyone here may have a no nonsense, lightweight approach for me, I would love to see it and try it out.
The urls where the physical MP3 files reside are listed in the script here.
I placed ?????? in the XML area for the ‘filesize’&’duration’ variables.
Many thanks to responders.
xml.php
[code]
<?php
session_start();
header(“Cache-control: private”);
if (!$_SESSION[’email’]) {
echo “You aren’t logged in.”;
exit();
}
echo “<?xml version=”1.0″?>n”;
echo “<songs>n”;
echo “<song artist='” . $_SESSION[‘username’] . “‘ title='” . $_SESSION[‘songtitle_1’] . “‘ duration='” . $_SESSION[‘????????’] . “‘ filesize='” . $_SESSION[‘????????’] . “‘ url=’../user_files/song1/” . $_SESSION[‘song_1’] . “‘ />n”;
echo “<song artist='” . $_SESSION[‘username’] . “‘ title='” . $_SESSION[‘songtitle_2’] . “‘ duration='” . $_SESSION[‘????????’] . “‘ filesize='” . $_SESSION[‘????????’] . “‘ url=’../user_files/song2/” . $_SESSION[‘song_2’] . “‘ />n”;
echo “<song artist='” . $_SESSION[‘username’] . “‘ title='” . $_SESSION[‘songtitle_3’] . “‘ duration='” . $_SESSION[‘????????’] . “‘ filesize='” . $_SESSION[‘????????’] . “‘ url=’../user_files/song3/” . $_SESSION[‘song_3’] . “‘ />n”;
echo “<song artist='” . $_SESSION[‘username’] . “‘ title='” . $_SESSION[‘songtitle_4’] . “‘ duration='” . $_SESSION[‘????????’] . “‘ filesize='” . $_SESSION[‘????????’] . “‘ url=’../user_files/song4/” . $_SESSION[‘song_4’] . “‘ />n”;
echo “<song artist='” . $_SESSION[‘username’] . “‘ title='” . $_SESSION[‘songtitle_5’] . “‘ duration='” . $_SESSION[‘????????’] . “‘ filesize='” . $_SESSION[‘????????’] . “‘ url=’../user_files/song5/” . $_SESSION[‘song_5’] . “‘ />n”;
echo “</songs>n”;
?>
And this is the XML it renders:
[code]
<?xml version=”1.0″ ?>
– <songs>
<song artist=”Allison” title=”Midnight Ride” duration=”???????” filesize=”???????” url=”../user_files/song1/16.mp3″ />
<song artist=”Allison” title=”Almost Me Again” duration=”???????” filesize=”???????” url=”../user_files/song2/16.mp3″ />
<song artist=”Allison” title=”Hope you Live” duration=”???????” filesize=”???????” url=”../user_files/song3/16.mp3″ />
<song artist=”Allison” title=”Midnight Ride” duration=”???????” filesize=”???????” url=”../user_files/song4/16.mp3″ />
<song artist=”Allison” title=”punched a hole in it” duration=”???????” filesize=”???????” url=”../user_files/song5/16.mp3″ />
</songs>
The member’s various mp3s all have the same name, just spread to 5 different folders.
Thanks