Creating an Audio Player in Flash

wdcoverWeb Designer, June 2004

With inspiration from modern MP3 players, we build our own fully functional player in Flash MX 2004.

Flash MX introduced the ability to load and play MP3 files directly at runtime. Prior to this, the only thing we could do was import the sounds into Flash at design time, or embed our sounds in SWF files and load those in at runtime. This was not an ideal solution, as it required hours of overhead and tedium.

Today, we have the ability to load an MP3 and play it streaming, so that it plays as it’s downloading and doesn’t need the entire song to begin producing sound. Also, we have access to the ID3 tags associated with most MP3 files.  This means we have access to information such as song title, album, artist and year.  It is these elements that are expected in a good MP3 player.

In Flash we have the ability to stop a stream and pick up from where we left off, without having to restart.  This, coupled with information about play head position and duration of the entire song, allows us to create a progress bar that represents the playback position.

We’ll be including all the standards; play, stop, rewind, next track and previous track. We’ll also be representing a playlist in an array.