Newest Articles

Photo Reel
Image Color Tinting using Actionscript
3d Rotating Image Cube
Image Slider with Easing
Catapult Game
Mp3 Player with XML Playlist


Popular Articles

True Fullscreen Flash Mode
FLV Player
Image Slider
Mp3 Player with XML Playlist
Album Slide
Page Flipper


Random Articles

Mp3 Player with XML Playlist
3d Rotating Image Cube
Photo Reel
Page Flipper
Image Slider
Falling Snowflakes


Links

Foundation-Flash
Tutorial4Me
MickM
TutorialQuest
Tutorialsphere.com - Free Online Tutorials
Photochopz
Newgrounds
TWiT
Link to SwfSpot
Swf Spot



rss feed

Mp3 Player with XML Playlist

Mp3 Player with XML Playlist
AddThis Social Bookmark Button
Description: Mp3s are loaded and played using an XSPF playlist
Author: John Bezanis
Added: November 25th 2007
Version: Flash 8
Total Views: 10640
Views in the Past 7 Days: 377


This mp3 player loads a playlist from an XML file using the GET parameter playlist. The GET parameter autostart determines whether or not to start playing the music as soon as the player loads. The quality of the sample songs has been reduced to lower bandwidth use and to avoid copyright issues.
Player Features:
  • Playlist loaded from an xml file
  • The ability to have music autostart or not on load
  • Full volume control
  • Alternating play/pause button
  • Buttons to advance to the previous or next song
  • Scrub bar to advance to any position in a song
  • Scrolling text
  • Scrollbar for the playlist
  • Clicking a playlist item starts that song
  • Autostart of the next song after a song has finished
Example code for the XHTML:
<object data="http://www.somesite.com/musicplayer.swf?autostart=true&playlist=http://www.somesite.com/playlist.xml" type="application/x-shockwave-flash" width="300" height="200"><param name="movie" value="http://www.somesite.com/musicplayer.swf?autostart=true&playlist=http://www.somesite.com/playlist.xml"/></object>

Example XML:
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
 <trackList>
  <track><creator>Iron Maiden</creator><title>Fear of the Dark</title><location>http://www.bezzmedia.com/swfspot/resources/42-song3.mp3</location></track>
  <track><creator>Social Distortion</creator><title>Ring of Fire</title><location>http://www.bezzmedia.com/swfspot/resources/42-song4.mp3</location></track>
 </trackList>
</playlist>


Download the files below:

Download XML File
Download Source File
Download the built Mp3 Player
Questions and Suggestions
thanks
November 29th 2007 18:11PM   -   kaghem
Riggght this is awesome but i want to add <songid>11232</songid> and when a button is clicked when that song is playing goes to a url/songid. Any idea how i can do this?
December 1st 2007 16:12PM   -   Damien Deakes
You could set up the xml file so it is dynamically processed by php. Instead of <songid>11232</songid>, have php replace the id 11232 with the actual mp3 url that the id links to.
December 2nd 2007 10:12AM   -   John
Hi john ive set that up already the php driven xml. But basically i have a php page at www.site.com/song/songid... and i want to link (via button) to that dynamic page for the current playing song.
December 2nd 2007 16:12PM   -   Damien
hey there. ok i love the mp3 player and it works great in a site that only has one playlist, but i am having trouble modifying the code for my website which has many different playlists. could you tell me where to change the code on the mp3 player if the name of the playlist is "acoustic_playlist" for example? then i think i can figure out the rest. great job :) sincerely, Jane Andre' jane@janesmusic.com
December 4th 2007 19:12PM   -   cynthia jane burrill
one other question i have is : how do i modify the code so that the music does not start automatically on load, but only when the use pushes the play button? thanks again, Jane Andre' jane@janesmusic.com
December 4th 2007 20:12PM   -   Jane Andre'
Jane, in the html, change both places where it says autostart=true to autostart=false
December 4th 2007 21:12PM   -   John
Anyone got a solution to my problem ... I want to link to the currently playing tracks informtion page... i already have <trackid>TRACKID</trackid> in the XML file, i just need to be able to insert a button which links to www.mysite.com/track/CURRENTLYPLAYINGTRACKID Any ideas. Would be greatly appreciated.
December 5th 2007 06:12AM   -   Damien
Where will we write this xhtml code? to swf?
December 5th 2007 13:12PM   -   aster
do you think to give some lessons about making spectrum analysis for music?
December 5th 2007 14:12PM   -   huseyin
huseyin, I believe you need to use AS3.0 to analyze the spectrum. Check out revolt: http://www.anttikupila.com/flash/revolt-actionscript-3-based-spectrum-analyzer-source-released/
December 5th 2007 18:12PM   -   John
Hey John, all I got to say is THANKS!!! I'm building a flash page for a friend that has a band and by adding this mp3 player to the page adds so much to it, it's amazing for bands. Thank you sooo much! If there's any paypal donation needed let me know... aragoneldragon@hotmail.com
December 12th 2007 03:12AM   -   Federico
I like mac much better and ipods i would prefer the ipod slider instead of that stupid playlist!
December 17th 2007 07:12AM   -   mikkel
How can i edit the player so it will accept this... <channel> <title>Podcasts</title> <description></description> <item> <title>traxexample8_oriental.mp3</title> <description></description> <itunes:author></itunes:author> <pubDate>Wed, 18 Jul 2007 11:58:44 +0100</pubDate> <enclosure url="http://www.hatfield.doncaster.sch.uk/user/59/54100.mp3" length="265968" type="audio/mpeg" /> <guid>http://www.hatfield.doncaster.sch.uk/user/59/54100.mp3</guid> </item> Cheers :)
December 18th 2007 05:12AM   -   Damien
this player is awsome, but anyone can fix the slider problem during streaming... it jumping left and right when the music still streaming
December 26th 2007 23:12PM   -   kevin
can i hide the playlist and call it we the user wants
December 27th 2007 23:12PM   -   maestro
undefined error
December 30th 2007 17:12PM   -   Robert
can't get it to work what am I doing wrong...built my own and that works....what do I need to implement to stop this error
December 30th 2007 18:12PM   -   Robert
Error opening URL "file:///G|/SwingSetGroup%5Finc/42%2Dmp3player/undefined",,,have all the files on local computer...do I need them on remote host....to test it?
December 30th 2007 18:12PM   -   Robert again
Robert, check your html and make sure you are pointing to the correct xml file.
December 31st 2007 12:12PM   -   John
Awesome... Thanks for the this, I don't know where you find the time to do it all
January 3rd 2008 16:01PM   -   Lee
Similar to Janes' post i'm trying to have the player only play the mp3 'on demand'. In other words when the user clicks the play button or song title only. I've set the auto start to: autostart=false and this prevents the player on initial load to not play.. however, after that, once you select a song the following songs auto-play. where can i stop that? Is this possible? BTW: This is an awesome mp3 Player!!! Thanks so much.
January 26th 2008 10:01AM   -   benny
Hi im trying to load this into a swf ive made myself using the loadmovie command but it wont play the mp3's, it does read the playlist and the animations all work but no music. :( can you help?
January 29th 2008 12:01PM   -   dobbin
Dont worry I fixed it, not sure what I did to fix it but it works like a dream now. BTW great player keep up the good work
January 30th 2008 07:01AM   -   dobbin
I'm building a site for my band and I wanted to use this player. However, the site I'm building is a Flash site. I've never worked with .xml. How do I get it to work if I'm not directly embeding the player though html? any suggestions? Thanks in advance.
February 5th 2008 08:02AM   -   Nino
I have the player working in a folder on my local machine, but when I post the same folder to my website, the player and all the information displays, but the mp3s don't play. Detail: In one failed instance the timer displays 00:00, in another, NaN:NaN.
February 22nd 2008 15:02PM   -   Bobby
Hey John Where in the actionscript i can change the code, that the loading progress is lower that i can play when it's already load's 2% of the music ? because if i put it on my website everey thing is going to a tild when it's loads the music. kind of regards, Djashuard
February 28th 2008 16:02PM   -   DJashuard
There are already a couple of posts on this subject but no solution yet.I also have different playlists on my site and I'm solving this now by putting different players on my site (one player.swf for each artist). There must be a way to load all the playlists(xml files or file) in the same player but how is this done? Anyone have an idea?
March 1st 2008 09:03AM   -   silky jack
Thank you very much. This is exactly what i needed. Great player!
March 3rd 2008 13:03PM   -   Levent
is there a way to read ID3 tags? I like you player
March 6th 2008 15:03PM   -   jorge
How do I change the font size and color of the playlistbox? Please help. Thanks, Louis
March 14th 2008 12:03PM   -   Louis
Player updated. It now uses the XSPF standard.
March 19th 2008 16:03PM   -   John
Hi... i'm quite new in "actionscripting" and would like to know if you can set the default volume in... let's say 50%, how can we do that?... by the way the mp3 flash is very good :)
March 28th 2008 02:03AM   -   sLo331
Esta mierda no anda!!!
March 30th 2008 13:03PM   -   cmtik
Hi! I would like to add this swf file insite my fla movie, I want to insert it in another movieclip so it lays as a swf file insite a Movie Clip (musicplayer_mc) Please help!
April 2nd 2008 09:04AM   -   Rasmus Eeg
Hi - Great Player! I was wondering if anyone might tell me how to go about adding a stop button? Many thanks!
April 3rd 2008 10:04AM   -   Francis
Francis--What's wrong with just having a pause button?
April 4th 2008 05:04AM   -   Frankie
There's nothing wrong with only having a pause button, and I like the play/pause toggle, feature but I'd just like to have a stop button as well. I've added the button in flash I just don't know what to add to the actionscript.
April 4th 2008 12:04PM   -   Francis
Hi, Does anybody know how tho change font style of the playlistbox? I think John already asked this question but can not see an answer to it. How do does this lines of code look like and where do you put them? My tries didn't work. Coba
April 16th 2008 06:04AM   -   coba
coba, to change the fonts, open the .fla in flash, click each text box, and change their fonts in the properties tab.
April 16th 2008 06:04AM   -   John
Hi, i have many question to u. My site is a free download music, i want this player swf have a download song and using code embed music to other site. Please help me, I have using playlist swf JW, i want using this script. Thanks so much
April 20th 2008 03:04AM   -   ken phan
Is there a way to configure the XML or the XHTML to do or not loop the playlist??
April 24th 2008 10:04AM   -   joanmanuel
Hi John, Great player, very responsive! Can you point me to any tutorials on how to display the album cover photo in a nested movie clip, that is triggered by the XML playlist?
May 15th 2008 11:05AM   -   Joe C
Thanks, I've managed to get it working fine, it's great
May 15th 2008 11:05AM   -   Paul
Nice topic Thanks I have found two interesting sources http://fileshunt.com and http://filesfinds.com and would like to give the benefit of my experience to you.
May 18th 2008 11:05AM   -   Natasha
How would you add a function that changed the playlist? I noticed that in the playlist.XML file it starts with <playlist version="1">, How would you make the play jump two <playlist version="2"> or load playlist2.XML?
May 19th 2008 12:05PM   -   Max Warburg (tyrant)
Hi Excellent player, I love it! Just wondering if anybody here knows what part of the actionscript must be edited to get the playlist to display when embedding the player into a new flash file. I have just copied the frames over into a new movie clip in a new fla file, and everything works just fine except the playlist window which displays nothing. I can't find what to edit in the script, and hope one of you might have the solution for me. I have found several good players with that works, but not as good as this one. Excellent work!
May 27th 2008 13:05PM   -   Paul
good work, ty..
June 4th 2008 22:06PM   -   theolbap
we are using your mp3 player,is there possiblity of displaying my thumbnail images for each song?
June 9th 2008 10:06AM   -   rajan
ok i have my playlist file but whenever i try to play a song on my pc i get this: Error opening URL " http://www.filefreak.com/pfiles/64927/electrikmp3/03%20Oh%20Foolish%20Heros.mp3 the mp3 at the url is valid though and when i have the swf online iit just does nothing and the box for song name says undefined-undefined the xml is here:http://electrikdesigns.50webs.com/42-playlist.xml and the swf is here:http://i169.photobucket.com/albums/u203/uluvjosh/mp3.swf please help :(
June 29th 2008 05:06AM   -   shua
shua, looks like your xml file is malformed. Try adding <?xml version="1.0" encoding="UTF-8"?> to the beginning.
June 29th 2008 08:06AM   -   John
ok i added the line but im still having the same problem. music refuses to play. i still get the same errors as my previous post states.. any more ideas. e-mail me at: musicboxdesigns@yahoo.com
June 29th 2008 17:06PM   -   shua
how do you update the xml so it sources the mp3 files from a folder (called mp3) rather than a web address?
July 2nd 2008 21:07PM   -   Franky Moops
Add a Question or Suggestion
name:
website (optional):
captcha type the characters into the box
message (5000 characters or less):