How To Create a Flash XML Playlist Music Player
Introduction
I have gotten quite a lot of requests on different tutorials that my visitors would like to see on the site and it’s really exciting. I just wish I had the time to keep up with you and give you all what you want. But hang in there, I will get to “that” exact tutorial you’re waiting for. I just have to take them one at a time.
This tutorial is a bit more complex than the other ones you can find on this site. Not necessarily harder, just a bit more code to pull it off.
It will cover all the steps necessary to get a working Flash XML MP3 Player for your site or blog. Necessary skills are once again basic. Software’s used are: Adobe Flash, Photoshop and a simple word processor of your choice for setting up your play list. I am using “Notes” on windows just to simplify. Also some knowledge on how to use a ftp client to upload your player and music to your server is needed.
PS: You can find a working example of the player at the bottom of this tutorial. Enjoy!
Step 1
As usual we need some graphics that will make up our player user interface. There are a million ways you can design your player and only your creativity is the limit. I have decided to take a somewhat classic way of designing my UI for this tutorial player.
What you should remember is to make several files. A file of each the buttons in their different states (i.e Hover, Press etc.) How many states you want your buttons to have is entirely up to you.
The functions this player will have is:
- Play Button
- Stop Button
- Previous Song Button
- Next Song Button
- Volume Slider
- Loader Bar
- Information Window – Song Title, Artist Name & Time
As you can see this player has all the necessary features to make any visitor appreciate the music you put on your site (remember: using copyrighted music without permission is a crime).
Also important to remember is if you’re using the Window Glass Shine on your information window, save the shine layer separately so we can put in the labels underneath the glass for better effect.
Here is my user interface design:

Step 2
Time to set up our flash document. Open a new project and use and set the following settings in “Publishing Settings…” under “File” (CTRL+Shift+F12).
Flash Tab:
- Version: Flash Player 9.0
- Load Order: Bottom Up
- ActionScript Version: ActionScript 2.0
- JPEG Quality: 100%
- Audio Stream: MP3, 160kbps, Stereo (this won’t affect the quality of the sound but I like to set it anyways)
- Audio Event: MP3, 160kbps, Stereo (this won’t affect the quality of the sound but I like to set it anyways)
HTML Tab:
- Quality: Best
There, now our publishing settings are set and it’s time to change some document settings. Open “Document Properties” and (if using the same dimensions as me on your user interface (182+102)) set the following:
- Title: “XML MP3 Player”
- Dimensions: 182 (width), 102 (height)
- Background Color: White (#FFFFFF) – (Optional, take what suits your interface best)
- Frame Rate: 30
Step 3
Now we’re going to set up our layers for the player. This time it’s a few more than usual. We need seven (7) layers this time so go ahead and add another 6 to the list.
After doing so name your layers, top to bottom, “actions“, “shine“, “text fields“, “buttons“, “loader / progress“, “volume” and “background“. That should be the layers we are going to work with. Of course you can go ahead and add any other layers that you need to make your user interface more interactive. But for this one we only need these.
Step 4
Let’s add our background to the setup. Go to “File” -> “Import” -> “Import To Stage…“. Your image should now be present on your stage. After your background image has been added to the stage make sure you align it correctly using you “Align” tool box to your right. Enable the “To Stage” button to your farthest right and then align it. This should but the background right where it’s supposed to be.
Now you should have something looking like this:

Step 5
Now, let’s add our little volume slider to the user interface.The first thing we have to do is to set the size of the movie clip itself that will hold our “Volume Slider”. So, let’s go ahead and create a rectangular shape using the tool box to the left. Make the rectangle fit the “Volume Bar” exactly. Should look like this (using red just to make it more visible for you. Will make it transparent later on so go ahead and use any color you like):

Now, select the red rectangle you just created and choose “Modify” -> “Convert To Symbol…“. Use the following title and settings:

Now we have our movie in the size that is needed for our “Volume Slider” to work as it is intended to. Now name (instance name) the movie clip “volume1“.
Double click the newly created movie click. We now enter the movie clips inside so we can manipulate the red rectangle along with adding our “Volume Slider”.
Select the red rectangle and once again choose “Modify” -> “Convert To Symbol“. This time use the exact same settings: Name the symbol “Slider“. We need to do this in order to be able to be able to manipulate the color of the red rectangle the way we want to. Set the instance name for our new symbol to “volBG“.
After doing this, if not already selected, select the red rectangle and go to “Properties” at the bottom of your screen. There you will find a choice named “Color” as a roll down menu. In the roll down menu choose “Alpha” and set the amount to “0%“. This will make our red rectangle transparent and won’t be in the way of our slider or make the bar look weird.
Time to add the “Volume Slider”.The little slider has been saved separately in Photoshop so we can interact with it and set the volume. While still in the movie clip let’s add the slider by importing it as usual using the “File” -> “Import” -> “Import To Stage...” procedure.
When it’s imported position it all the way to the right on your “Volume Bar” to set the volume to maximum when the player is initiated.
We need to create a movie clip out of our “Volume Slider” as well. So let’s repeat the “Modify” -> “Convert To Symbol…” and name it “Volume Controller“. Again using the same settings as we used previously. Remember, use the same layer as the red rectangle is on. No need to create a new layer. As instance name set it to “dragger“.
You should now have something looking like this:

Step 6
OK, we got our volume control graphics set up. Now it’s time to set up our loader bar/play progression bar. This will be done almost the same way so remember the “Convert To Symbol” procedure.
Alright, let’s create the loader movie to begin with. Create a 168*2 pixel bar where the loader indicator is positioned on our user interface. Here’s how it looks like on my user interface:

Now we have to convert this shape into a Movie Symbol again. Again, “Modify” -> “Convert To Symbol…“. Name it “Loader Bar” and set it to “Movie Clip“. Set the instance name to “loaderer“.
When we have done this, double click on the newly created movie clip to get inside it. In here we’re going to set up our loader bar. The bar that will indicate how much of the song is loaded. What we need to do first is to create a new layer to house our progress bar. Name the new layer “progression“. So, again create a bar (pick a color of your choice) that will represent the loader.
I have chosen a blue color for my loading progression bar. We once again have to create a movie clip out of our bar. So once again: “Modify” -> “Convert To Symbol…“. Name the symbol “Progression” and here is an important step. You have to set the focal point to top-left corner for the loading progression bar to progress from left to right when loading.
Now, make the width of your newly created progression bar movie clip to 1 pixel in the “Info” section in your toolbox to your right. Set the instance name to “loaderBar“. Now the Loading Progression Bar is all set up.
What we need to do before leaving the insides of this clip is to get rid of the main movie clip size adjuster background. So, let’s convert the background to a “Graphic” layer with the same procedure as usual. “Modify” -> “Convert To Symbol…“. Pick the “Graphic” option and name it “Loader Background”.
After converting the background graphics to “Graphic” again use the Roll Down menu in the “Properties” box found at the bottom of your screen when selecting your newly created “Graphic” symbol. Choose “Alpha” and set it to “0%” to make it transparent.
Here’s how my complete setup looks like:

Ok, now the loading progression bar is all set up. What we’re going to do now is to use the loader bar as our player head progression bar as well. Nifty right?! What we need is an indicator that will move along the progression bar as the song is being played to show where in the song we are currently located.
If you haven’t already, go back to your root, the beginning flash project layout by clicking “Scene 1“. Let us now import our 4*4 pixel player head to the stage using the usual procedure. “File” -> “Import” -> “Import To Stage…”
Alright with the player head imported, position it on the farthest left of your loader bar. After doing this we again need to convert it to a Movie Symbol to make it usable as a player head.
“Modify” -> “Convert To Symbol…“. Name it “Player Head” and pick the “Movie Clip” option. Don’t forget to set the focal point to the top left corner. Give your newly created movie clip the instance name “playHead“.
After doing all this you should have something looking like this:

Step 7
Wow, we have come a long way already in 7 steps. All the tricky parts are now over and now we come to the more basic functions of the music player. It’s time to set up our Play, Stop, Prev and Next buttons.
When I saved the background for my player I also saved each button in it’s “inactive” state as well as “active” state separately. Let us start by importing the “Play Button” to the “buttons” layer and to the stage. I presume you know by now how to do this so I won’t go in to that again.
After importing the play button (inactive) position it right where it’s supposed to be. OK, all done. Now, let’s convert this graphic button into a “Button” symbol. Same procedure as usual. Name the button symbol “Play Btn – Inactive” and set the instance name of your newly created button symbol to “play_btn“.
Now we have our first button. Double click the button to enter the buttons different state stages. As you can see the “Up” stage is already there. What we need to do right now is to import a our play button graphics in it’s active state.
Select the “Over” frame and create a blank key frame. This is done by right clicking the empty “Over” frame and selecting “Insert Blank Keyframe“. With this done we can now import the “active” state of the button. So, import the play buttons active graphics to our newly created key frame in “Over“.
We now have a working “Play” button.
Repeat this with all the three other buttons giving them the instance names: “stop_btn“, “prev_btn” and “next_btn“.
There, our important music player buttons are all in place and you should have something looking like this. Pay attention to the “Play” button as it is in an active state. Just to show how they look in active state.

Step 8
To display “Song Title”, “Artist Name” and “Time” we need to set up some labels. This we will easily do. We are going to add three (3) dynamic text fields in the “text fields” layer with the instance names: “timeDisplay_txt“, “bandDisplay_txt” and “titleDisplay_txt“.
Remember to “embed” the font to store it in to the Flash file when published. This way the texts will look the same no matter what visitor sees it.
The aligning of the labels are entirely up to you how you want them to present the information. Just remember to drag the artist name and the song title text fields to their maximum available space as they otherwise will get cut if you have an artist name or a song title that is too long.
This is how I aligned my three labels:

IMPORTANT: Remember that the artist name and title is only for you to see where I have positioned the different labels. Before you save and publish you player you should just make them blank.
Step 9
Nice! Now our labels are all setup as well. Just a few things remaining now before we can publish and test our new masterpiece. Now comes the easy part. Adding the “shine” layer to the player to make it more realistic in it’s appearance.
In the “shine layer”, import the shine layer to the first frame.
You can either import a PNG file with 100% opacity and then convert the shine into a “Graphic” layer and the add the “Alpha” color to it or you can just save a PNG in Photoshop that already has the opacity set to 20% or whatever shine strength you prefer.
You should now have something like this:

Step 10
Now comes the heavy part. Don’t be discouraged though. I will lead you through the entire process and try to explain what it all means. It’s time for the core. The code to make our player work as intended. It’s not as complicated as it looks so just stick with me.
In the first frame of our “actions” layer add this all this code explained underneath. You open the “actions” window by either right clicking on the first frame in our “actions” and choose “Actions” at the bottom of the list or you can just press “F9“The full code will be presented in the end. I just want to go through the parts of it so you understand what the code does.
stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songband = [];
_global.songfile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songband[i] = playlist.firstChild.childNodes[i].attributes.band;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
//trace(songname[i]+” “+songfile[i]+” “+songband[i]);
}
}
_root.createEmptyMovieClip(“sound_mc”, 1);
_global.song_nr = random(songfile.length);
//_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
OK, lot of code here. No worries. I am going to explain the main parts of it.
Line 1 – Just makes sure that our flash movie doesn’t loop and re-setup our player. Instead it stops and waits for us to interact with the player, such as pressing the play button.
Line 2 – Creates a variable for our play list later created in an XML file.
Line 3 – Will simply ignore any line breaks in our play list to make sure it’s read from top to bottom correctly.
Line 4 through 12 – scans out play list for the information such as Song Title, Artist Name and File and puts them in variables later accessible for our player when pressing the Play button.
Line 13 – sets up our sound channel. Opens it if you will.
Line 14 – randomizes the place where the player starts playing in the play list.
Line 15 – As you can see I have two slashes in front of the line. This is because if we didn’t the player would start playing automatically as soon as it’s loaded. If you want this function just take off the two slashes and you player is all setup to start playing as soon as it loads.
Line 16 – Closes the function.
There, let’s move to the next part of the script.
function timer(sound_obj) {
time = sound_obj.position/1000;
min = Math.floor(time/60);
min = (min<10) ? “0″+min : min;
sec = Math.floor(time%60);
sec = (sec<10) ? “0″+sec : sec;
timeDisplay_txt.text = min+”:”+sec;
}
This function is all for the timer of the player. Showing how much of the song that has been played. Let’s go through the code.
Line 1 – Opens up the timer procedure of the sound channel allowing us to keep track of where the player head is located.
Line 2 – Creates a variable holding the total length of the song.
Line 3 – Calculates the number of minutes that has passed.
Line 4 – If total amount of minutes are less than 10 we add a zero in front of the number to keep our layout the same.
Line 5 – Calculates the number of seconds that has passed.
Line 6 – If total amount of seconds are less than 10 we add a zero in front of the number to keep our layout the same.
Line 7 – Sends and prints our result to our “timeDisplay_txt” instance label.
Line 8 – Closing our function.
Now our timer is all set up and it’s time to move on over to the part that actually handles the play operation. This includes the sound channel setup and our volume control.
MovieClip.prototype.songStarter = function(file, name, band) {
if (this.sound_obj) {
this.sound_obj.stop();
delete this.sound_obj;
}
this.sound_obj = new Sound(this);
this.sound_obj.loadSound(file, true);
this.onEnterFrame = function() {
if (this.sound_obj.position>0) {
delete this.onEnterFrame;
this._parent.titleDisplay_txt.text = “‘”+name+”‘”;
this._parent.bandDisplay_txt.text = band;
this._parent.timeDisplay_txt.text = “00:00″;
timeInterval = setInterval(timer, 1000, this.sound_obj);
} else {
this._parent.bandDisplay_txt.text = “Loading…”;
}
};
this.sound_obj.onSoundComplete = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = “00:00″;
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
this._parent.volume1.dragger.onPress = function() {
startDrag(this, true, 1, this._y, this._parent.volBG._width-10, this._y);
this.onEnterFrame = function() {
var p = (this._x/this._parent.volBG._width)*100;
this._parent._parent.sound_mc.sound_obj.setVolume(p);
};
};
this._parent.volume1.dragger.onRelease = function() {
delete this.onEnterFrame;
stopDrag();
};
this._parent.volume1.dragger.onReleaseOutside = function() {
stopDrag();
};
};
This time it’s a lot of code. Again, no worries. It’s all pretty straight forward.
Line 1 – Opens up our songStarter function. Starts it off.
Line 2 through 5 – Checks if something is currently playing. If it is, then that object is stopped and deleted.
Line 6 – Creates a new sound channel for our song.
Line 7 – Loads the file currently in line in our play list.
Line 8 – Opens up a “This Frame” function. Meaning whenever our flash movie enters this frame this function will be executed.
Line 9 through 10 – Checking if the position of the player head is larger than 0. If it is it’s deleted.
Line 11 through 13 – Resets all the labels and the timer to blank and zero.
Line 14 – Resetting the timer interval.
Line 15 through 17 – If labels and timer already is reset “Loading…” is printed out to our bandDisplay label.
Line 18 – Function closed.
Line 19 – Opens up a new function. This function handles the “next” track when the current track has been played to the end and is completed.
Line 20 – Resets the interval.
Line 21 – Resets the “Timer” label to “00:00″.
Line 22 – Adds one to the play list counter location and progresses to the next track in the play list.
Line 23 – Locates, loads and starts the next track in the play list.
Line 24 – Function closed.
Line 25 – Opens up volume dragger function – The onPress function.
Line 26 – Checks the newest position of the volume dragger.
Line 27 – Opens up an onEnter Frame function to locate the dragger at initialization.
Line 28 – Sets the minimum and maximum “x” limits of our volume dragger.
Line 29 – Sets the volume according to the location of the volume dragger.
Line 30 – Function (volume onPress) closed.
Line 31 – Function (SoundComplete) closed.
Line 32 – Opens a onRelease function for the volume dragger.
Line 33 – Resets the dragger on Frame enter.
Line 34 – Stops dragging.
Line 35 – Function closed.
Line 36 – Opens an (outside release) onRelease function.
Line 37 – Stops dragging.
Line 38 – Function closed.
Line 39 – Main function (songStarter) closed.
A lot of code there huh? But it wasn’t that hard was it? On to the code that handles the loader bar and the progression indicator. This part is somewhat easier and not so complex.
setInterval(soundStatus,100);
function soundStatus(){
var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded() / _root.sound_mc.sound_obj.getBytesTotal();
_root.loaderer.loaderBar._width = amountLoaded * 168;
duration = _root.sound_mc.sound_obj.duration;
position = _root.sound_mc.sound_obj.position;
_root.playHead._x = position / duration * 165+6;
}
Line 1 – Resets our soundStatus interval to 100.
Line 2 – Opens up a soundStatus function.
Line 3 – Creates a variable to hold the amount loaded.
Line 4 – Checks the total amount of bytes for our song file.
Line 5 – Sets total file size to be 100% of the loader bar. (168 being the total width of my loader bar)
Line 6 – A variable holding the current duration of the load.
Line 7 – A variable holding the current location of the load.
Line 8 – Sets the width of our loader bar to the current progress in percentage.
Line 9 – Function closed.
That should be it for our loader progression bar. Now let us head on to our buttons. This is the fun part actually setting up some user interaction with our player. Let’s take a button at a time.
play_btn.onRelease = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = “00:00″;
_root.playHead._x = 7;
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
Line 1 – Opens up a “play_btn” onRelease function. This will be executed each time you press the “Play” button.
Line 2 – Resets the timeInterval variable.
Line 3 – Resets the timer label to “00:00″.
Line 4 – Brings our player head back to start position.
Line 5 – Starts the current song loaded.
Line 6 – Function closed.
Easy huh? Not much to it was it. Now our “Play” button should be working all good. On to the “Stop” button.
stop_btn.onRelease = function() {
clearInterval(timeInterval);
_root.playHead._x = 7;
this._parent.timeDisplay_txt.text = “00:00″;
this._parent.titleDisplay_txt.text = “”
this._parent.bandDisplay_txt.text = “”;
this._parent.sound_mc.sound_obj.stop();
};
Line 1 – Opens up a “stop_btn” onRelease function. This will be executed each time you press the “Stop” button.
Line 2 – Resets the timeInterval variable.
Line 3 – Brings the player head right back to it’s starting position.
Line 4 – Resets the timer label to “00:00″.
Line 5 – Resets the “Song Title” label to blank.
Line 6 – Resets the “Artist Name” label to blank.
Line 7 – Stops the current song playing on our sound channel.
Line 8 – Function closed.
That’s out “Stop” button interaction completed. Now both our “Stop” and “Play” buttons should be working as intended. Now what remains is our “Next” and “Prev” song buttons. Let’s go straight to the “Next” button code.
next_btn.onRelease = function() {
clearInterval(timeInterval);
_root.playHead._x = 7;
this._parent.bandDisplay_txt.text = “Loading…”;
this._parent.timeDisplay_txt.text = “00:00″;
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
Line 1 – Opens up a “next_btn” onRelease function. This will be executed each time you press the “Next” button.
Line 2 – Resets the timeInterval variable.
Line 3 – Brings the player head straight back to it’s start position.
Line 4 – Adds “loading…” to bandDisplay label.
Line 5 – Resets the timer label to “00:00″.
Line 6 through 7 – Gets the next Song info in the play list and starts loading it. After loading it automatically starts playing.
Line 8 – Function closed.
That should wrap up our “Next” button interaction. Now all that’s left of the button’s is the “Prev” button interaction code. Let’s do it.
prev_btn.onRelease = function() {
clearInterval(timeInterval);
_root.playHead._x = 7;
this._parent.bandDisplay_txt.text = “Loading…”;
this._parent.timeDisplay_txt.text = “00:00″;
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr–;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
Line 1 – Opens up a “prev_btn” onRelease function. This will be executed each time you press the “Prev” button.
Line 2 – Resets the timeInterval variable.
Line 3 – Brings our player head right back to it’s starting position.
Line 4 – Adds “loading…” to our bandDisplay label.
Line 5 – Resets the timer label to “00:00″
Line 6 through 7 – Gets the previous song info on the play list and starts loading it. After loading the song will start automatically.
Line 8 – Function closed.
Well, that should be all of our button’s. The button interaction is now all completed and there is only one thing left we have to add to our code in order to make it work properly. We of course have to load our play list. Our XML file not yet created. It’s only one line so it should be really easy.
playlist.load(“playlist.xml”);
Line 1 – Basically loads our play list from the file location. If using a folder or a sub folder you can just go ahead and add the pathway for it not including the root. For example. If I am using a folder called “XML Player” my code would look like this:
playlist.load(“/XML Player/playlist.xml”);
Simple huh?
Our code is now all done and all that is left to do now is actually to create our play list and then upload the whole thing to our server.
Step 11
The last thing we’re going to do in creating our XML Mp3 Music Player is to create our XML file. This is the main part of our Player and it’s what we’ll be modifying ever once in a while to switch up music for our player. Remember, using copyrighted music without permission is a crime.
Now let us see how our play list shall be setup correctly. Open your favorite word processor and type or copy the following (accept you using your own songs). My play list is looking something like this. I am using songs from my yet unreleased album so enjoy the preview. And yes, I am also a writer/producer.
<?xml version=”1.0″ encoding=”UTF-8″?>
<songs>
<song name =”Give Her A Break” band =”Richard Darell” file=”/site player/Give Her A Break.mp3″ />
<song name =”Leavin Me Numb” band =”Richard Darell” file=”/Site Player/Leavin Me Numb.mp3″ />
<song name =”Hollywood Movie” band =”Richard Darell” file=”/Site Player/Hollywood Movie.mp3″ />
</songs>
As you can see it’s neither hard or complicated. Actually it’s very structured.
Line 1 – Tells the browser/computer that this is going to be an XML document.
Line 2 – Tells our player that this is the start of our play list.
Line 3 -
- The “song name” is where you will be putting the “Song Title” for your song.
- The “band” is where your “Artist Name” goes.
- Finally “file” is where the location of your song will be found.
Pretty simple right? Just keep adding songs as many as you like.
Line 4 – Tells our player that this is the end of our play list.
Alright, the Music Player should now look something like this being done:

Yeah, that should be it. Time to actually save our Flash movie and get it published before we open up our favorite FTP software to upload it to our server.
Step 12
With everything set up correctly and everything ready all that’s left to do is to save our newly created player and then publish it before we upload it.
So, save your project as “Website Player” by “File” -> “Save” or by pressing “Ctrl+S“. After saving our player let’s publish it by going to “File” -> “Publish“.
There. The final step was finally completed. Now what we have to do is to upload it to a server and test it. Don’t forget to upload your song to your chosen location.
Step 13
Alright, now when our Music Player is all created, saved, published and uploaded to our server, we need to add the HTML code to our blog/website where we want to place it.
The HTML code you will be adding anywhere of your choice is looking like this:
<object classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0″ width=”180″ height=”100″ id=”Website Player” align=”middle”>
<param name=”allowScriptAccess” value=”sameDomain” />
<param name=”allowFullScreen” value=”false” />
<param name=”movie” value=”/site player/Website Player.swf” />
<param name=”quality” value=”best” />
<param name=”bgcolor” value=”#ffffff” />
<embed src=”/site player/Website Player.swf” quality=”best” bgcolor=”#ffffff” width=”180″ height=”100″ name=”Website Player” align=”middle” allowScriptAccess=”sameDomain” allowFullScreen=”false” type=”application/x-shockwave-flash” pluginspage=”http://www.macromedia.com/go/getflashplayer” />
</object>
There, that should be all. Now test you player to make sure it works as intended. Here is an example of my player. Go ahead and try it out.
Working Example
Round Up
Wow, that went fast! As you can see it’s quite simple to add a complex music player to your website without too much work. I am sure you are able to create this player within an hour or so if you have a clear idea what kind of user interface you want to create.
I am also sure your visitors will enjoy a little music while they read your blog or surf your site. This player is super solid and stable so go right ahead and use it in any way you like.
I hope you have enjoyed this tutorial as much as I have enjoyed writing and creating it. There are plenty more tutorials on the site to enhance the experience for your visitors that visits your site or blog. You are more than welcome to check them out.
Now I’m off for a little break before I will hit the computer again to create another tutorial I’ve had in my mind for ages now.
Looking forward hearing from you so please comment if you have the time.
Thank you!
Popularity: 34% [?]
Dang, you code, teach, and sing! Your talent is unlimited man. Great inspiration and tutorial.
[Reply]
Robert Banh – Thanks buddy! Well, I try to do my best. Guess it’s my add luriking about not letting me befriending stillness.
[Reply]
[...] Minervity » How To Create a Flash XML Playlist Music Player Good tutorial for creating a flash music player with XML! (tags: webdevelopment flash music xml player) [...]
That’s a great tutorial and all. But you said that you were gonna put the full code at the end. I don’t see it?
XD
[Reply]
Mike – I did that didn’t I. Crap, I totally forgot about that. My first priority when I get back to the office!
Sorry about that.
[Reply]
lol that’s cool..
well here is a php script I wrote last night to go along with your flash mp3 player.
It parses your xml info from playlist.com
Flash isn’t exactly my strong point XD
mp3 = $data;
break;
case $xml_artist_key:
$track_array[$counter]->artist = $data;
break;
case $xml_song_key:
$track_array[$counter]->song = $data;
$counter++;
break;
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, “startTag”, “endTag”);
xml_set_character_data_handler($xml_parser, “contents”);
$fp = fopen($xml_file, “r”) or die(“Could not open file”);
//$data = fread($fp, filesize($xml_file)) or die(“Could not read file”);
$data = stream_get_contents($fp);
if(!(xml_parse($xml_parser, $data, feof($fp)))){
die(“Error on line ” . xml_get_current_line_number($xml_parser));
}
xml_parser_free($xml_parser);
fclose($fp);
echo “\n”;
echo “\n”;
for($x=0;$x<count($track_array);$x++){
echo “song . “\”" . ” band =” . “\”" . $track_array[$x]->artist . “\”" . ” file=” . “\”" . $track_array[$x]->mp3 . “\” />\n”;
}
echo “”;
?>
[Reply]
oh well it didn’t let me paste the whole thing over =/
well just shoot me an email if interested.
blade@razerclan.com
[Reply]
[...] How to Create an Flash XML Playlist Music Player: Just something really cool that you can make for your site/blog. [...]
[...] Don’t forget that there are plenty of other tutorials on this site that will enhance the feel of your website for your every visitor. Everything from Count-Up’s and Live Visitor Counter’s to Expansive XML Music Player’s. [...]
I finished the tutorial, pretty sure I did everything word for word (with the exception of using Flash 9, I only have Flash 8). I had to change all of the quotation marks to straight quotations so it would continue to publish and I had to fix a syntax error in line 102 (output told me to!). So I got it set up on a little test page, running straight from the my computer (and not a server), it’ll do the loading thing, bring up the little timer, but it never loads the song.
Here is the ActionScript:
stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songband = [];
_global.songfile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songband[i] = playlist.firstChild.childNodes[i].attributes.band;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
//trace(songname[i]+" "+songfile[i]+" "+songband[i]);
}
}
_root.createEmptyMovieClip("sound_mc", 1);
_global.song_nr = random(songfile.length);
//_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
function timer(sound_obj) {
time = sound_obj.position/1000;
min = Math.floor(time/60);
min = (min<10) ? "0"+min : min;
sec = Math.floor(time%60);
sec = (sec0) {
delete this.onEnterFrame;
this._parent.titleDisplay_txt.text = "‘"+name+"‘";
this._parent.bandDisplay_txt.text = band;
this._parent.timeDisplay_txt.text = "00:00";
timeInterval = setInterval(timer, 1000, this.sound_obj);
} else {
this._parent.bandDisplay_txt.text = "Loading…";
}
};
this.sound_obj.onSoundComplete = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = "00:00";
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
this._parent.volume1.dragger.onPress = function() {
startDrag(this, true, 1, this._y, this._parent.volBG._width-10, this._y);
this.onEnterFrame = function() {
var p = (this._x/this._parent.volBG._width)*100;
this._parent._parent.sound_mc.sound_obj.setVolume(p);
};
};
this._parent.volume1.dragger.onRelease = function() {
delete this.onEnterFrame;
stopDrag();
};
this._parent.volume1.dragger.onReleaseOutside = function() {
stopDrag();
};
};
setInterval(soundStatus,100);
function soundStatus(){
var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded() / _root.sound_mc.sound_obj.getBytesTotal();
_root.loaderer.loaderBar._width = amountLoaded * 168;
duration = _root.sound_mc.sound_obj.duration;
position = _root.sound_mc.sound_obj.position;
_root.playHead._x = position / duration * 165+6;
}
play_btn.onRelease = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = "00:00";
_root.playHead._x = 7;
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
stop_btn.onRelease = function() {
clearInterval(timeInterval);
_root.playHead._x = 7;
this._parent.timeDisplay_txt.text = "00:00";
this._parent.titleDisplay_txt.text = ""
this._parent.bandDisplay_txt.text = "";
this._parent.sound_mc.sound_obj.stop();
};
next_btn.onRelease = function() {
clearInterval(timeInterval);
_root.playHead._x = 7;
this._parent.bandDisplay_txt.text = "Loading…";
this._parent.timeDisplay_txt.text = "00:00";
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
prev_btn.onRelease = function() {
clearInterval(timeInterval);
_root.playHead._x = 7;
this._parent.bandDisplay_txt.text = "Loading…";
this._parent.timeDisplay_txt.text = "00:00";
(song_nr==0)? _global.song_nr=songfile.length-1 : _global.song_nr--;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
playlist.load("playlist.xml");
Here is the XML:
The HTML:
Untitled Document
[Reply]
Glenn – The code given here are straight copied and pasted from the flash project in itself. When checking there are quotation marks in there and I get no errors what so ever.
I am using Flash CS3 and make sure you use ActionScript 2.0 and no Script Assist.
I will include the Flash Project later this week into all my tutorials, new or old, so that you all can check it there.
I honestly have no idea why it won’t work on your client. Maybe it’s just the version of Flash you are using. And, without trial and error I can’t check if it works alright.
Hang in there and I will incorporate the Flash Project (finished) at the bottom of each tutorial.
[Reply]
Hi, thanks for this tutorial! It looks very promising, but it is the second ActionScript tutorial that I have followed for the purpose of creating my own media player and I haven’t been able to get either to work.
Similarly to Glenn I found that the Flash CS4 compiler really didn’t like the smartquotes. Using find and replace caused a few more problems, and after manually changing them all I was still left with two syntax errors:
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr–;"The above code causes a syntax error but the compiler output doesn’t say anything more specific about what caused it.
The second syntax error is apparently caused by the very last closing curly-brace
};right before the XML file is loaded.I suppose I must have made some errors myself, because unlike Glenn my player does nothing at all. The only output I get from the movie is the background and the button animations. You also mention Script Assist, where is this accessed?
Thanks in advance, the tutorial was very well written and easy to understand (certainly one of the better ones available) so I strongly suspect I have made some error here myself.
[Reply]
Hey,
Great tutorial, I was just wondering (upon searching for a while I couldn’t find the answer, hence the question) what would have to be added to also display the next and previous tracks if play order isn’t randomized? Thanks in advance!
Dan T
[Reply]
Dan T – Well, simple really. You will have to add two more variables that would fetch the track info (-1) and (+1). This would then hold the information you are after even if it’s randomized.
Somewhat like this:
this._parent.sound_mc.songStarter(songfile[song_nr-1], songname[song_nr-1], songband[song_nr-1]);
and
this._parent.sound_mc.songStarter(songfile[song_nr+1], songname[song_nr+1], songband[song_nr+1]);
…and just set the new “labels” to show these seperate values.
Hope that helps.
[Reply]
Yes ty that works very well
[Reply]
[...] How To Create a Flash XML Playlist Music Player [...]
I have the same problem as James said on 26th february.
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr–;”
This gives an syntax error. And my music player won’t play music.
So, can anybody help us?
Linda
[Reply]
Hi Linda,
In that piece of code you quote above, there’s a bit missing. The code should read:
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr--;
hope that helps
Kristen
[Reply]
lani Reply:
April 2nd, 2010 at 3:33 pm
thank you! that fixed mine except it is having trouble loading the playlist-
it just stays at “loading” when i press play-
any thoughts?
thank you!
[Reply]
how i can do for use multiplaylist, example i can change playlist.load(”playlist.xml”) for use a variable like this
playlist.load(listname) or how??
thanxs
[Reply]
Thanks for this! Great tutorial!
About what Glenn was saying: for some reason, when you pasted the code into the website, it formated it for you, making the simple (straight) quotations become smart (curved) quotations. Because of how strict ActionScript is, this becomes an error. For those of you encountering this, the fix is simple, just do a CTRL+F (CMD+F for Macs) and replace the quotations in the script with one that you typed in yourself.
As for the “syntax error” in the “prev_btn” that Glenn also mentioned, the formatting turned “–” into a longer dash. Simply take the big dash at the end of the code, and replace it with two minus signs.
Now for my question! haha. I sell music on my site, but would like to allow listeners to listen to them through this player. I’ve got it working, and everything is great! My only concern is security, since someone could just navigate to my MP3 directory. Is there anyway to get around this? If I keep the files in a protected folder, will the program still be able to access them?
Thanks a lot!
[Reply]
Hi there everyone, I’m having problems getting my mp3 player to work. When I test my movie in flash (using flash cs3 btw)the songs do not play and I get an output message saying Error opening URL”*filesourcehere*”.
Can anyone help me find where its going wrong? The actionscript contains no errors and the xml Script is exact to the one above, only with my files and songs of course. Any help would be much appreciated.
[Reply]
Good tutorial!! Thanks for sharing.
[Reply]
hi Twinster,
wow, what a great tutorial…
but i have a problem with my loader bar…
the loader head starts out of the position where the progression loads and the progression fully loads when played.
hope you can help me…
thanks…
[Reply]
Hi – great tutorial and (after a couple of syntax errors on my part) I’ve got everything running pretty smoothly – thanks!
My question tho’ – how can I get the player to start at the beginning of a playlist, instead of random?
Thanks!
[Reply]
Thank you, this tutorial was great. I was wondering how to incorporate a multiple playlist of songs that is displayed in player and not have it start randomly.
Matt
[Reply]
hey, thanks for the tut. when i try to start it however, it has an error opening my xml file. any help?
[Reply]
Wow, i am glad i found this tutorial! Looks long and tough, but i do not think there is any other tutorial out there that is as descriptive as this one! It is just what i was looking for! Thank you! Great job!
[Reply]
I don’t suppose you could upload the flash file for the one you made I seem to be having alot of issues using CS4!
If you could it would be very much appreciated!
[Reply]
[...] This post was Twitted by Ripst3r [...]
Hi. Loved this toturial.
To the problem, everything workes smooth aslong as im only testing the SWF movie inside of flash but at the moment I open it externaly I can’t load any tracks.. Its stuck on “Loading..”.
Anyone stuck at the same place and knows how to fix it?
Once again thanks for a great tutorial.
[Reply]
Fixed it ^^.
[Reply]
lani Reply:
April 2nd, 2010 at 3:35 pm
how did you fix it?
im having the same problem!
thanks!
[Reply]
possible to put a downloadable fla + xml file?
[Reply]
Hello Twinster
great tutorial
I have no errors in flash but it is obbious from the output error below it can not find the xml page.
Also I had to change all of the Quotation marks to PRIME marks, ther was no errors after that.
Error opening URL ‘file:///C|/Documents%20and%20Settings/jim/My%20Documents/My%20Doc%20G%20%20%20%20%20%28web%20%26%20Info%29/FCF%20Lighthouse/Flash/undefined’
thanks for help
jim
[Reply]
Hi Twinster
great tutorial but I am having trouble with it trying to locate the xml page.
I am getting this error when I CTRL + Enter in flash
Error opening URL ‘file:///Flash/playlist.xml’
I get this error when I press play or next
Error opening URL ‘file:///C|/Documents%20and%20Settings/jim/My%20Documents/My%20Doc%20G%20%20%20%20%20%28web%20%26%20Info%29/FCF%20Lighthouse/Flash/undefined’
thanks
jim
[Reply]
Hey there, I have followed the tutorial to the last detail, even spent all day creating my player. There is one slight problem…
I have “fixed” the quotation marks and I have uploaded to a test page along with everything needed, XML file, folder with music in etc… and well, The player has no syntax errors, the player just does not want to load the music. Every time I press play or even next or previous, it just wont load. Here is the script I copied and pasted. I send it just incase there is anything I missed out. Please help, thanks!
stop();
playlist = new XML();
playlist.ignoreWhite = true;
playlist.onLoad = function(success) {
if (success) {
_global.songname = [];
_global.songband = [];
_global.songfile = [];
for (var i = 0; i<playlist.firstChild.childNodes.length; i++) {
_global.songname[i] = playlist.firstChild.childNodes[i].attributes.name;
_global.songband[i] = playlist.firstChild.childNodes[i].attributes.band;
_global.songfile[i] = playlist.firstChild.childNodes[i].attributes.file;
trace(songname[i]+" "+songfile[i]+" "+songband[i]);
}
}
_root.createEmptyMovieClip("sound_mc", 1);
_global.song_nr = random(songfile.length);
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
function timer(sound_obj) {
time = sound_obj.position/1000;
min = Math.floor(time/60);
min = (min<10) ? "0"+min : min;
sec = Math.floor(time/60);
sec = (sec0) {
delete this.onEnterFrame;
this._parent.titleDisplay_txt.text = "‘"+name+"‘";
this._parent.bandDisplay_txt.text = band;
this._parent.timeDisplay_txt.text = "00:00";
timeInterval = setInterval(timer, 1000, this.sound_obj);
} else {
this._parent.bandDisplay_txt.text = "Loading…";
}
};
this.sound_obj.onSoundComplete = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = "00:00";
(song_nr==0)?_global.song_nr=songfile.length-1:_global.song_nr--;
_root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[song_nr]);
};
this._parent.volume1.dragger.onPress = function() {
startDrag(this, true, 1, this._y, this._parent.volBG._width-10, this._y);
this.onEnterFrame = function() {
var p = (this._x/this._parent.volBG._width)*100;
this._parent._parent.sound_mc.sound_obj.setVolume(p);
};
};
this._parent.volume1.dragger.onRelease = function() {
delete this.onEnterFrame;
stopDrag();
};
this._parent.volume1.dragger.onReleaseOutside = function() {
stopDrag();
};
};
setInterval(soundStatus,100);
function soundStatus(){
var amountLoaded = _root.sound_mc.sound_obj.getBytesLoaded() / _root.sound_mc.sound_obj.getBytesTotal();
_root.loaderer.loaderBar._width = amountLoaded * 168;
duration = _root.sound_mc.sound_obj.duration;
position = _root.sound_mc.sound_obj.position;
_root.playHead._x = position / duration * 165+6;
}
play_btn.onRelease = function() {
clearInterval(timeInterval);
this._parent.timeDisplay_txt.text = "00:00";
_root.playHead._x = 7;
this._parent.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
stop_btn.onRelease = function() {
clearInterval(timeInterval);
_root.playHead._x = 7;
this._parent.timeDisplay_txt.text = "00:00";
this._parent.titleDisplay_txt.text = ""
this._parent.bandDisplay_txt.text = "";
this._parent.sound_mc.sound_obj.stop();
};
next_btn.onRelease = function() {
clearInterval(timeInterval);
_root.playHead._x = 7;
this._parent.bandDisplay_txt.text = "Loading…";
this._parent.timeDisplay_txt.text = "00:00";
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
};
prev_btn.onRelease = function() {
clearInterval(timeInterval);
_root.playHead._x = 7;
this._parent.bandDisplay_txt.text = "Loading…";
this._parent.timeDisplay_txt.text = "00:00";
(song_nr==0)?_global.song_nr=songfile.length-1:_global.song_nr--;
_root.sound_mc.songStarter(songfile[song_nr],songname[song_nr],songband[song_nr]);
playlist.load("playlist.xml");
};
[Reply]
[...] This post was Twitted by dogzbydogz [...]
I’m having the same problem as Jim. The player is working fine when I test it in flash but I get an output error for each of the items in my xml file. It says,
Let’s Party! http://dudemanbro.com/music/dudemanbro_thatsawesome/01_letsparty.mp3 undefined
Never Gonna Live It Down http://dudemanbro.com/music/dudemanbro_thatsawesome/02_nevergonnaliveitdown.mp3 undefined
DUDEMANBRO, That’s Awesome! http://dudemanbro.com/music/dudemanbro_thatsawesome/03_dudemanbro_thatsawesome.mp3 undefined
etc.
Any ideas?
[Reply]
Twinster Reply:
July 28th, 2009 at 9:08 am
Have you checked the filepath so it’s entirely correct. When working in a browser it’s always case sensitive.
[Reply]
Ok I think I figured out the undefined error. Each song I was using was from the same band so I wanted to omit the band name. You can’t just leave it out in your xml file you have to put band=”. That should get rid of the undefined error.
I having another problem though. I can’t seem to get the embed code to work. Here’s the code I’m using;
And here’s the website where it should be. http://www.dudemanbro.com
Any ideas what I’m doing wrong?
Thank you.
[Reply]
Hi,
great tutorial by as I got to the end I encountered this problem for the ending of the text on Flash 8. When I typed the action script code for the previous button i received this:
**Error** Scene=Scene 1, layer=actions, frame=1:Line 118: Operator ‘-’ must be followed by an operand
(song_nr == 0) ? _global.song_nr=songfile.length-1 : _global.song_nr-;
Is there something I did wrong?
Thanks!
–Matthew.
[Reply]
Twinster Reply:
July 28th, 2009 at 8:48 am
Yeah I think there is something wrong with the font in this blog and it makes it look like a single”-” when it should be two “–” after each other.
[Reply]
how do autoplay ?
[Reply]
Twinster Reply:
July 28th, 2009 at 8:44 am
There is a setting that is disabled in the script that you can just go ahead and take off the tags in front of and you will have autoplay enabled.
[Reply]
Thanks for sharing this tutorial, but I’m not having any success!
Same problem with Jim, I get an error in the OUTPUT, saying: ‘file:///HOOTCHI/PastisserieCLOVER/CareyOttMusicPlaylist/undefined’.
All my files are in the same folder: xml file, mp3 file, flash file, so linking should be straight forward. Any ideas why my player won’t play?
Thanks so much!
[Reply]
Richard Darell Reply:
August 6th, 2009 at 11:29 am
What version of Flash are you using and also have you set the ActionScript to 2?
[Reply]
it’s Flash CS4 but i’ve set the setting down to flash 9.0 and actionscript 2.0. As soon as I did that, the quotation problem that I had was gone. But still, no mp3 is playing. Help!
PS. does the player support other audio files other than mp3s?
thanks again!
[Reply]
I am using adobe flash CS3 pro and I have set the actionscript to 2.0. Tested the case sensetivity of the directory paths and file names. I cannot get the thing to play any music. Please help.
[Reply]
Sorry for the doubble post. Maybe you could have the working script as a downloadable file? I really need this script as its what I am after. Other scripts I have found are not as customisable as yours.
[Reply]
Only codes one time but I snagged the entire tutorial for later use!
You are awesome. Coding was on a Compac 45. Made it play music!
HAH.
[Reply]
@jim, gabe, & and everyone else who may still have error loading file. i figured out what it was..just a minor syntax error. look closely to the beginning of the error message (file:///..) there’s not supposed to be 3′/’s and that extra slash is from the xml file so just simply take the first ‘/’ out from the file URL and you’re lock n load
Richard (twinster), i have told my wife about you today ever since i came across this excellent tutorial last night. we both agree you are indeed a rare breed for someone who’s so accomplished and yet so down to earth. unlike you, i’m still quite new at flash coding (still stuck at as2), but at least, we have love for games, design and helping others. hope more great tutorial to come when you find time off from writing great songs.
all the best
[Reply]
Hi, Nice post! I am a novice to AS, and this has helped me to learn a lot. Thank You.
Can anyone help me in writing a code for the pause button in this? I am not able to figure it out yet!
Thanks a lot!
Cheers.
[Reply]
For people having “undefined” errors.
Retype the quotation mark in the XML file, copy and paste causes a syntax error in the XML file so the mp3 will not be able to load into the Music Player.
Cheers.
[Reply]
Richard Darell Reply:
November 4th, 2009 at 1:51 am
Good pointer. Thanks!
[Reply]
NEED HELP!!! ok my flash play perfect BUT only when all the associated files are in folder together! If I put all the files together but one, my “home” page, and then set the links on the home page the flash file gets stuck on “Loading”!!! ANYBODY????
[Reply]
having seen that next and previous select songs that don’t exist bringing up the error message that all before me have published.
I used the debugger and watched the variable _global.song_nr
I could see that the next button resulted in the incorrect song being played similarly the previous button was also playing the wrong song.
the sequences where playing
next 0 1 2 3 the song not played when _global.song_nr was 3 caused error
previous 1 2 3 0 the song not played when _global.song_nr was 0 caused error.
the lines
(next)
(song_nr == songfile.length-1) ? _global.song_nr=0 : _global.song_nr++;
_root.sound_mc.songStarter(songfile[song_nr+1], songname[song_nr+1], songband[song_nr+1]);
shows a loop with limits songfile.length-1 and _global.song_nr=0 where the _global.song_nr is incremented (++)
unfortunately the next line
_root.sound_mc.songStarter(songfile[song_nr+1], songname[song_nr+1], songband[song_nr+1]);
is telling the sound player to play the song after (+1) the song indicated by our _global.song_nr variable so when the loop has counted to song 3 (_global.song_nr=3)it tries to play song 4 which if you only have 4 songs which are 0 1 2 3 it doesnt exist and gives error.
conversely the previous button is coded to play the song -1 so it also runs out of songs when (_global.song_nr=0) its playing song -1
simple solution is to play the .song_nr and not .song_nt+1 or .song_nr-1
just change the last line of the previous button function prev_btn.onRelease = function()
from:
_root.sound_mc.songStarter(songfile[song_nr-1], songname[song_nr-1], songband[song_nr-1]);
to:
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
and the next button function next_btn.onRelease = function()
from:
_root.sound_mc.songStarter(songfile[song_nr+1], songname[song_nr+1], songband[song_nr+1]);
to:
_root.sound_mc.songStarter(songfile[song_nr], songname[song_nr], songband[song_nr]);
yes you will notice both are now the same and both will work because they both play the song pointed to by the variable
_global.song_nr (alias song_nr)
The important thing is learning how to use the debugger to watch the variables you think may be holding vital information.
[Reply]
Great tutorial, really simple to follow and very nicely structured.
The only thing that has stummped me is that after completing the tutorial and uploading it to a test server is that when i click play it loads the song as shown by the loader progress bar but the song doesn’t start playing
any idea what could be causing that?
cheers
[Reply]
Hmmm… It’s worthless tutorial without posting the source files!
[Reply]
Great tutorial. The only thing I’m having problems with is that only the first song is random. Am I wrong in thinking that its supposed to randomize the entire playlist? Also, every time use use the at the bottom I get an error.
I was able to add album art to by adding to the xml and using loadmovie.
Website: http://www.twinpros.com/mixtape.cfm
FLA file: http://www.twinpros.com/hiphop_player.fla
[Reply]
Awesome tutorial. I’m having a problem when publishing the player, in my computer (flash) it seems to work, but unfortunately it doesn’t on the .fla or website… any suggestions?
[Reply]
Which string of code enables the player to move onto the next song once one stops playing?
[Reply]
Hi. i just went through the gay tutorial and i copied all the code like i was supposed and it give me 19 friking errors about syntax errors and what not! sry for being po-ed but can u blame me… 19.. i rechecked everthing 20 times does anyone know why this is? i check and you said as2 so its in as2 and all the mc and btns all have the right instance names and what not… grr… pls help someone! lol
[Reply]
Excellent tutorial, thank you very much for this. Too bad about the formatting. A lot of people will get stuck with that.
[Reply]
Dear Richard,
This tutorial is amazing, thnx so much!
I’m now ading my own things but I’m stuck with 1 thing.
Make the bar draggable so that you can quickly jump to a position of a track.
Can you explain how to do this?
GR
[Reply]
I am on step 5 and I am confused as to what you mean when you say “So, let’s go ahead and create a rectangular shape using the tool box to the left.” Are you talking about the rectangle tool (R) in the tool bar to the right of my screen? And if so, I tried that and selected my spot where I designed to have the volume bar in photoshop but after I select it, it doesn’t highlight the box in red (or any color) like yours does. Am I suppose to be in the “volume” tab like in the pic or am I supposed to be on that layer itself, because when I click “Layer 7,” it highlights the area I designed to have the volume bar.
Schmitty
[Reply]
was good but I did not play music, where did I go wrong I can not find
[Reply]
First of all, very good toturial!
But I’m on the same path as Jeffrey;
Make the bar draggable so that you can quickly jump to a position of a track.
Can you explain how to do this?
Best regards,
[Reply]
To start dragging use the startDrag action script
To play at a certain point of the music use the
sound_mc.sound_obj.start((location in %) * duration/1000);
Thanks
Blinks
this._parent.loaderer.playHead.onPress = function() {
if (!playHead_drag) {
playHead_drag = true;
startDrag(this, true, 1, this._y, this._parent.loaderbarbg._width-10, this._y);
}
};
this._parent.loaderer.playHead.onRelease = function() {
playHead_drag = false;
sound_mc.sound_obj.start(this._x / 197.8 * sound_mc.sound_obj.duration/1000);
stopDrag();
};
this._parent.loaderer.playHead.onReleaseOutside = function() {
playHead_drag = false;
stopDrag();
};
[Reply]
to everyone who has had trouble with the stuck at loading problem- i finally found the solution!!
with the file paths, in the xml file AND the actionscript, write out the entire web address:
xml file:
before:
after:
last line of action script:
before:
playlist.load(“player/playlist.xml”);
after:
playlist.load(“http://www.lanitrock.com/player/playlist.xml”);
hope this helps! i’ve been doing this all day!
thanks for the awesome tutorial!!
now if only i could get the volume slider to work…
[Reply]
That is perfect that people can get the credit loans moreover, this opens up new possibilities.
[Reply]
Good tutorial so far but it seems to be for a more advanced flash developer I’m totally new to flash. So could anyone please help me out I don’t know how to “set the focal point” to top-left and I don’t know how to insert a blank keyFrame. I see where UP is highlighted but clicking on over does nothing over is in an inactive state so I’m stuck right there. I’m trying to keep up and assuming that for each stage we click on the layer we are working on for instance when working on the buttons click on the button layer etc. But there is a bit of assumption that you know how to use flash already. If you have any input for this Flash noob I would greatly appreciate it.
[Reply]
I need help quickly.
Do I need to put the text fields on separate key frames?
[Reply]
Heidi C. Reply:
April 21st, 2010 at 6:44 pm
project due tomorrow….heeeeeeeelp
[Reply]
Heidi C. Reply:
April 28th, 2010 at 5:52 am
too late…silly question anyway
[Reply]
does anybody has a zip file with the player working?
im not getting things ok (really noob on flash)
and this is just perfect for what im looking for
thanks
[Reply]
This is a great tutorial! It will definitely come in useful.
[Reply]
Hey,
Great tutorial but i got 2 errors:
Line 25 Syntax error: sec = (sec0) {
Line 31 ‘else’ encountered without matching ‘if’: } else {
What to do???
[Reply]
I have a music website with flash player with playlist xml fixed – I mean the webpage when opened loads flash player with particular movie songs list. I want to have a dynamic playlist where user click play button the flash player should load in new window and load the song he has clicked and when he again clicks(or clicks add to quicklist) on other movie song on other webpage it should get added to the list.
[Reply]
Hi There, great player. It would be great if you could let it receive the the playlist file name dynamically thru flashvars. eg;
playlist.load(“flashvars”);
This would be a perfect addition.
How can this be done? on the as3 side of things.
[Reply]
Hi,
Was just wondering if you know how to remove the “music by ……” from bottom of template. Can’t seem to find it anywhere!?
Please help!
Isis
[Reply]
Your post is really informative for me. I liked it very much.
[Reply]
Newest style of NFL jerseys has arrived, get the details at nfljerseys-shopping.com.. Purchase cheap jersey here since football jerseys are having promotion now.
[Reply]
Discount Wholesale Electronics, Wholesale Cell Phones, Electronic Gadgets and More from the Best Dropship Wholesaler
[Reply]
Instead of loading an xml playlist, I would like to load a text field with links from an xml file. The text field would have a description of a song that includes a link that when clicked would load the song into the player.
xml link would be something like:
“Description of Song.”
Listen To Song
action script would be something like:
_root.sound_mc = new Sound();
_root.play = function(url) {
_root.sound_mc.loadSound(url, true);
}
Sound loads but player inoperable. I’m wondering if I need to incorporate “sound_obj” into the above script so that player is functional?
[Reply]
Leave a comment!
Friends & Partners
10 Steps
Abduzeedo
Andy Sowards
BittBox
Brian Cray
Colorburned
CrazyLeaf Design
Design Bump
DesignFalvr
Design Reviver
Design Shard
Design Your Way
Digigirl
From The Couch
Fudge Graphics
Fuel Your Creativity
GoMediaZine
Good-Tutorials
Hongkiat
I Am Khayyam
ImJustCreative
InstantShift
Just Creative Design
Krftd
Line25
Loon Design
Mashable
MyInkBlog
Naldz Graphics
Noupe
Obox Design
Outlaw Design Blog
PhotoshopGirl
Photoshop Roadmap
Printed Proof
PSD Fan
PSDTuts+
Six Revisions
Smashing Magazine
Speckyboy
Spoon Graphics
Spoonfed Design
The Design Superhero
Tutorial9
Tutorial King
Tutorial Magazine
TutZone
Vandelay Design
VectorTuts+
Webdesigner Depot
Web Design Ledger
We Are Not Freelancers
Random Posts
Latest Video Post
Recent Posts
Most Commented
Most Popular