Flash->PHP->flash (getting MP3's duration)

I’m building myself a flash site, and I need to get the duration of a song while being loaded. usind mp3file.duration while loaded gives the loaded segment duration and not the whole file, and getting to the id3 tag via flash is possible only when downloading is finished.

So, I want the flash sending a URL parameter (containning folders like “tracks/alternative/mymusic.mp3”) to this PHP file and getting back the duration.

I don’t know PHP and only recently I started struggling with action script. Does anyone know what’s the code I need to put in the PHP and how I make the flash communicate with it?

— Edit: I got help —

using getID3 and the following code in a PHP file:

$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($_GET[“filename”]);
echo “<XML>”.$ThisFileInfo[‘playtime_seconds’]."</XML>";

Then calling it by:

function getDuration():Void {
    durationXML = new XML();
    durationXML.ignoreWhite = true;
    durationXML.load("duration.php?filename=" + run_url);
    durationXML.onLoad = function() {
        xml_duration = (durationXML.firstChild.firstChild.nodeValue);
        run_duration = (parseFloat(xml_duration));
        durationLoaded = true;

This will put the duration of a “folder/file.mp3” in the var run_duration.

I hope it’ll help others as it helped me :slight_smile: