Ludicrous Software

ID3 Data in Flash Lite

Hayden drew my attention to some information about accessing an MP3’s ID3 tag data from within Flash Lite. I did a little playing around with this on the W910i, and here are the results. It seems like the fscommand2 method of accessing this data does not work on the W910i - or more precisely, I couldn’t get it to work! Some Googling turned up further information, and some of the code samples include a loadVariables call before the fscommand2. Further Googling turned up this page on accessing this info specifically from the W910i. My German is non-existent, but I can read code. :)

It turns out that for the 910, you need to use loadVariables(“MP://data”, root); to get at the ID3 tag info. This little script will load the ID3 variables into a movie clip, then iterate through all the properties of that clip and copy them into a text string on the root timeline:

var dbg:String = new String();
function getMeta() {
  loadVariables("MP://data", tagInfo);
  dbg = "";
  for (var i:String in tagInfo) {
    if (i != "_movieClipLoaded") {
      dbg += i + ": " + tagInfo[i] + newline;
var tagInterval:Number = new Number();
tagInterval = setInterval(getMeta, 1000);

Copy that onto frame one of a fla, put a dynamic text field on the stage that displays the value of the variable ‘dbg’, and create a placeholder movie clip off-stage that has an instance name of ‘tagInfo’. Get a song playing via the Walkman music player on the phone, and fire up the swf. You should see ID3 info displayed on the stage. If you’d rather save some time, just download this zip file with the fla and swf. If you’re going to play around with this, here are some things to keep in mind:

  1. I first tried load the ID3 info into a movie clip created at runtime via ActionScript, but this wouldn’t work, hence the off-stage placeholder movie clip.
  2. It looks like you can only access the song title, album name, and artist name from the MP3 file, with variable names of TITLE, ALBUM, and ARTIST, respectively. I haven’t checked, but I’m pretty confident that the MP3 files I put on my phone include pretty extensive ID3 tag data, and the for … in statement should show every property of the tagInfo clip (except for the _movieClipLoaded property, which we don’t care about).
  3. Showing this information is primarily of interest if you’re building screensavers/wallpaper, but you can also access the data from a swf launched from the file manager. Like the accelerometer, you cannot access this data from a swf loaded via http.