Skip to main content
September 12, 2013
Answered

ID3 tag data in AIR project question

  • September 12, 2013
  • 1 reply
  • 786 views

Hi

Couple of questions if you are able to help.

1. Is it possible to read ID3 data from a file object, or do you have to create a Sound, and send the file object's nativePath data to the Sound?

eg

public var snd:Sound = new Sound();

public function Sound_id3Example(file:Object) {

           

            snd.addEventListener(Event.ID3, id3Handler);

            snd.load(new URLRequest(file.nativePath));

}

2. If it HAS to be via a Sound, and I'm using a recursive function/loop to load files/file data from a directory (and am also trying to read id3 data during that loop), how do you make a recursive function wait until the ID3 event listener has fired before moving on to the next file?

Thanks for taking a look.

This topic has been closed for replies.
Correct answer sinious

It's ideal to use the ID3 system because it will parse it for you. If you're using Adobe AIR you can use the FileStream class to read the file directly and extract the ID3. ID3V1 is at the end of the file, you can read up on the spec here:

http://en.wikipedia.org/wiki/ID3#ID3v1

Set the FileStream.position either 128 (standard) or 227 (extended) bytes from the end of the file and just read the tag. You'll have to parse what is returned via the spec. You can use FileStream synchronous or asynchronous. You'd probably want async so your app doesn't freeze on a big directory.

1 reply

sinious
siniousCorrect answer
Legend
September 12, 2013

It's ideal to use the ID3 system because it will parse it for you. If you're using Adobe AIR you can use the FileStream class to read the file directly and extract the ID3. ID3V1 is at the end of the file, you can read up on the spec here:

http://en.wikipedia.org/wiki/ID3#ID3v1

Set the FileStream.position either 128 (standard) or 227 (extended) bytes from the end of the file and just read the tag. You'll have to parse what is returned via the spec. You can use FileStream synchronous or asynchronous. You'd probably want async so your app doesn't freeze on a big directory.

September 15, 2013

Thanks Sinious!

sinious
Legend
September 16, 2013

You're welcome