Using AudioPlayback in Flash CS3
In Getting Started, we created a simple AudioPlayback component with a form field to input the audio url. In this example, we will allow the user to populate a playlist through the form field. The player will then cycle through the songs on the playlist.
For starters, let's go ahead and import all the classes we will need for the tutorial.
We will need the following variables
continuosPlayindicates whether the player will cycle back to the first song after the last one is played
playlistis an array that will hold all of the audio urls in the playlist
counterwill be used to track the current song
We will need the following component for our application:
TextInputfield for the user to enter songs to add to the playlist.
Buttonto submit the input into the playlist
Buttonto load the playlist into the player
Buttonto manually advance the playlist
Buttonto move to the previous song
CheckBoxthat indicates whether
continousPlayis set to true.
The main function for managing the playlist is
playClips. It moves to the next or previous song based on the position in the playlist, the
increment parameter and the value of
Next we'll add the event handlers.
For managing the playlist we have event handlers attached to the AudioPlayback component's
mediaEnded event as well as the
Finally, we have handlers for the continuous play check box and the
Example: AudioPlayback with Playlist
To see a live example, please install Adobe Flash Player version 9 or higher.
Download the FLA file.
For additional information, please take a look at the Examples section for functional demonstrations and the ActionScript 3.0 Class Reference for full details on every property, method, and style available to the AudioPlayback component.