+65 8180 0424
This tutorial is dedicated to Juan, who wrote to me saying “It may be too much asking but have you thought in loading a songlist from an XML”, which gives me this bright idea to write a tutorial on ‘Mini Audio / MP3 player in flash’.
The credit surely goes to Actionscript 3 for the all their new features including ‘pause’.
We will be covering a lot of topics whilst creating mp3 player, topics include,
For better understanding of ‘list component’ and ‘sound classes’, shall write about the same in different sections.
Let’s begin with ‘List Component’, which is also the first step in creating Flash MP3 player.
List Component –
Next step is to get the player up and running. To accomplish the above, we will have to provide an EventListerner to our List Componenet ‘tracklist’ to check for song selection, grab the song url / data from tracklist, check if the song is loaded, or if there is an error while loading and to play. There is another very important thing which I HAVE TO mention. As you all are aware, to play a song, we will have to create a ‘Sound Object’ and allot play method to Sound Object for playing select music, but the problem here is, we cannot just finish with this, because there is a ‘Memory leak’ problem with AS3. To overcome this problem, we will have to create a ‘player object’ and then allot sound object to the same.
Functionalities for buttons and sliders are also included
var sc:SoundChannel=new SoundChannel();
//sound events for 'complete', 'error' and 'progress'
var rect:Rectangle = new Rectangle(0,-5,100,0);
I hope the explanation and script was simpler to understand.
Click here to download the source code
- Downloadable source code file also includes script for slider.
The slider didn't seem to work properly over the net so I removed it from this tutorial and thought of retaining the same in source code file, just in case, if you need it.