Week 7: Building an MP3 Player

In this exercise we build an MP3 player that not only dynamically loads the sound from an XML document but also digs into the ID3 data in the songs to give the listener a bit more information than a song title.

This exercise closely follows an excellent tutorial written by Derek Franklin in Flash MX 2004, Actionscript, Training From the Source by Macromedia Press. I don't believe in in reinventing the wheel and Derek's books are superb resources for students and teacher alike.

ID3 and MP3 Files

MP3 files contain a lot more than the data that contains the music. They also contain "metadata" which contains such information as:

In fact , if you use iTunes or the Windows Media Player you have seen this data. The interesting thing about this is, Actionscript can also access it . Thus you can create some relatively robust audio applications without having to do a serious amount of extra work. Also, if the ID3 data isn't present you can always add it through iTunes and the Windows Media Player.

ID3 Data in iTunes

Image 1: The ID3 data in iTunes is displayed in the Get Info dialog box and clicking the Info tab.

ID 3 infor in Windows Media Player.

Image 2: The ID3 info is available in the Windows Media Player.

Note: The songs provided in this lesson are royalty-free songs available on Flashkit and their availability and use are subject to the Terms of Use from Flashkit. Also be aware that not all MP3 songs contain ID3 data or tags.

When you load an MP3 into a sound object, the ID3 properties are accessed by reading the object's ID3 properties. Extracting this data, such as the song's title,is done using the following syntax:

var songName:Text = music.ID3.TIT2;

Other common ID3 properties include:

In this lesson we will be constructing an MP3 player that not only plays the song but also displays the ID3 data in the interface.

Next..Building the player.


This work is licensed under a Creative Commons License.