ASTRA AudioPlayback
AudioPlayback is a UI component that creates a set of controls for audio playback.
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 playedplaylistis an array that will hold all of the audio urls in the playlistcounterwill be used to track the current song
We will need the following component for our application:
playlistInput- aTextInputfield for the user to enter songs to add to the playlist.playlistButton- aButtonto submit the input into the playlistloadButton- aButtonto load the playlist into the playernextButton- aButtonto manually advance the playlistpreviousButton- aButtonto move to the previous songcontinuosPlayToggle- aCheckBoxthat indicates whethercontinousPlayis 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 continousPlay
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 previous and next buttons.
Finally, we have handlers for the continuous play check box and the playlistButton and loadButton buttons
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.