Ok, so this will elicit a "duh" out of my Flex 2 experienced readers, but I was pleasantly surprised to find that Flex 2 (to be clear, ActionScript 3) can read the ID3 tags out of MP3 files. I knew that I could play MP3s in Flex, but I didn't realize I could also dig out the ID3 information.

Like most things in Flex 2, it is incredibly easy. First you load a MP3:

sound = new Sound(new URLRequest("/music/80s/EURITHMIX-SWTDREMS.MP3"));

That's a relative URL there to an Apache virtual alias on my local server. Next you add an event listener:

sound.addEventListener(Event.ID3, onID3);

This basically says to run the onID3 function when the ID3 event fires. My demo onID3 method looked like so:

function onID3(event:Event):void { myid3info.text += sound.id3.songName + "\n"; myid3info.text += sound.id3.artist + "\n"; }

Where myid3info was a simple text control. Flex supports all the typical properties (album, artist, song name, etc). More information may be found at the Livedocs page.

I'd post a demo, but the last thing I need is a RIAA lawsuit. ;) FYI - I discovered this gem in the ActionScript 3.0 Cookbook.