Wednesday, July 28, 2010

Sound class in Actionscript 3: Part 3

Today we will learn how to find out information about the mp3 playing, such as song name, album, artist and more.

Mp3 files can contain a lot of metadata. Usually the file contains the name of song and album, names of the performer and composer, genre, year etc. These are the id3 tags and can be retrieved using id3 property of Sound object.

ID3 tags contain properties: artist, album, songName, track, year, genre, comment.

You can find those out like this:


To use the code above, we first need to wait for the id3 tags to load into swf. We need to create an event listener to tell us when can we ask the server about the id3 tags.

The event we are going to use is called Event.ID3:

mysound.addEventListener(Event.ID3, getID3);
function getID3(Event){

I know it was a short tutorial, but I think this is a useful thing to know when working with audio files.


Sound class in Actionscript 3: Part 1
Sound class in Actionscript 3: Part 2
Sound class in Actionscript 3: Part 4
Sound class in Actionscript 3: Part 5
Sound class in Actionscript 3: Part 6


Ademar said...

I can't get ID3info, from a library mp3 file linked!

Is it possible to do?

Thank You

Kirill Poletaev said...

The method I've given is used to read ID3 tags off external mp3 files. It appears that the sounds stored in library do not contain ID3 data.

If I find a solution, I'll let you know. Also, if anyone else knows the answer to this problem - please share it with us.

Post a Comment