Week 7: Building an MP3 Player : Reviewing what you have
In this lesson we will be concentrating only on the code that creates the Player.
If you have opened the PlayitEx.fla file you will notice that there are a number of layers:
Background: This layer contains an interface constructed in Fireworks MX 2004.
Text: This layer contains the Dynamic Text boxes that will hold the ID3 data extracted from the currently playing tune.
Components: This layer contains a list component (UI Components) which has the instance name playlist_lb.This component will display a list of the songs in the XML document and will allow the user to select a song for playback.
Buttons: This layer contains two invisible buttons that will trigger the start and the stop of the song that is selected in the List component.
Actions: This is where it will all happen.
How this player works is relatively uncomplicated. When the movie starts, the song titles will be extracted from the XML document and added to a list which is displayed in the List component. The user will select a song and click the Play button. When the Play button is clicked, the song will play and the ID3 data will be displayed in the Text fields.
Image 3: The file for this exercise contains a number of layers that all have a specific purpose.
The XML file - playlist.xml- contains only the basic information necessary to access the music and load the mp3 file. The code in the XML file is:
<Playlist>
<Song URL="Agent00.mp3">Agent 00</Song>
<Song URL="HardCope.mp3">Hard Cope</Song>
<Song URL="LoungeJam.mp3">Lounge Jam</Song>
<Song URL="Prosonica.mp3">Prosonica</Song>
</Playlist>
As you can see, the only items in the document are the location of the song and its name. This data will eventually be pulled out of this file and appear in the List component on the left hand side of the interface. The great thing about using an XML document is that you can add songs to the player without opening the Flash file and they will appear automatically in the List component.
Next....Accessing the XML and Lists
![]()
This work is licensed under a Creative Commons License.
