Simple AS3 MP3 Player

Last night I was browsing around 365psd.com and I found a very interesting design for an mp3 player. Then I thought it would be a good idea to make it functional with Flash and ActionScript 3.0 and then share it for free on my blog 😀

Source files:

  mp3_player.zip (1.4 MiB, 9,978 hits)

Similar Posts

15 Comments

  1. Hi,

    I’ve question about Simple AS3 mp3 player.
    When it’s loaded the music play automaticly.
    How can I do that after loaded this the music doeasnt start automaticly.

    Best wishes,
    Tomasz

  2. function playMp3()
    {
    	snd = new Sound();
    	snd.load(new URLRequest(mp3List[whoIsOn]));
            //sndChannel = snd.play(); <========this is now a comment==
    	snd.addEventListener(ProgressEvent.PROGRESS, progressHandler);
    	snd.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    	sndChannel.addEventListener(Event.SOUND_COMPLETE, sndComplete);
    	sndTransform.volume = .9;
    	sndChannel.soundTransform = sndTransform;
    	controls.playPause.gotoAndStop("pause");
    }

    i highlighted the piece of code that you can either delete or comment out by putting "//" in front of it.

  3. Hey, just so you know I found a small bug. If you pause the sound, then scrub to a position it’ll start playing again, which is fine, but it doesn’t change the play button back to pause. So you can hit the play button and it starts the sound again and you then have 2 sounds playing simultaneously. It can be remedied simply by adding

    controls.playPause.gotoAndStop("pause");

    to the soundScrub function.

    Other than that it works great, and thank you as I will be using it as a reference for an mp3 player I am building.

  4. Hy, thx you guys for this source

    I’ve question, how about autoreplay?
    Because, i’ve find that, when a song was ended, it was unable to load the next song.

    Thx

  5. Hello,
    thx for the code but i have a problem with a code witch give me “TITLE” and “ARTIST” in a dyn.TXTfield.
    please help me!

    Thank you!!

  6. If anyone else has this issue regarding not autoplaying with other MP3 files.
    Add the following at the end of the soundProgress() function. Seems to do with Event.SOUND_COMPLETE not firing, so we need to detect ending another way/

    function soundProgress(event:Event):void 
    {    
    	var loadTime:Number = snd.bytesLoaded / snd.bytesTotal;
    	var loadPercent:uint = Math.round(100 * loadTime);
    	var estimatedLength:int = Math.ceil(snd.length / (loadTime));
    	var playbackPercent:uint = Math.round(100 * (sndChannel.position / estimatedLength));
    	controls.progressBar.scaleX = playbackPercent/100;
    	duration = estimatedLength;
    
    	trace(playbackPercent);
    	if (playbackPercent>=100) { //force next song
    		whoIsOn++;
    		if(whoIsOn >= mp3List.length)	{
    			whoIsOn = 0;
    		}
    		playMp3();
    	}
    
    }
  7. Before you load a new song, make a random number for the whoIsOn variable. Something like:

    whoIsOn = Math.round(Math.random()*mp3List.length);
  8. Hi, thanx for your answer. I have one more question. Player on my website playing some songs…
    All song’s in mp3. I thought that it safety policy, but some songs play…Maby you can promt me the reason…

  9. Hi, my problem is the sound progress line does not move according to my mouse click, when i change the size of player.

    Thanks in advance

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? Please solve:Captcha