PDA

View Full Version : The best way to make an MP3 player in 8


Stantz
02-20-2007, 03:24 PM
Hey guys.

I have tried to make a simple MP3 player that plays external files. I have 12 buttons each with a sound attached, when you click on one the sound plays. I have included at the end some of the script used.

I would like to make this more advanced by adding a stop button that only stops the sound (the one i setup at the moment stops everything else). And i would like to incorporate a volume slider.

If you know of any tutorials that could help me create a MP3 player such as this with external files that would be great, or any advice would be useful.

Thank you.
Raymond.

On each button, eg:

on (release, keyPress "2") {
p.loadSound("lab/2.mp3", true);
}

Defined actions on separate controller layer, one of each sound, eg:

p = new Sound();

The button i used was:

on (release) {

p.stop();

}

But it stops everything. Thanks again.

Stantz
02-20-2007, 03:26 PM
Hey everyone.

I have been trying to create a simple MP3 player that plays external files. I have 12 buttons each with a sound attached, when you click on one the sound plays. I have included at the end some of the script used.

I would like to make this more advanced by adding a stop button that only stops the sound (the one i setup at the moment stops everything else). And i would like to incorporate a volume slider.

Any advice would be useful. Please be gentle i am very new to Flash.

Thank you.
Stantz.

On each button, eg:

on (release, keyPress "2") {
p.loadSound("lab/2.mp3", true);
}

Defined actions on separate controller layer, one of each sound, eg:

p = new Sound();

Cota
02-20-2007, 06:11 PM
Read it, love it, enjoy it
http://kennybellew.cowfly.com/tutorial/

jsonchiu
02-21-2007, 07:33 AM
Hey guys.

I have tried to make a simple MP3 player that plays external files. I have 12 buttons each with a sound attached, when you click on one the sound plays. I have included at the end some of the script used.

I would like to make this more advanced by adding a stop button that only stops the sound (the one i setup at the moment stops everything else). And i would like to incorporate a volume slider.

If you know of any tutorials that could help me create a MP3 player such as this with external files that would be great, or any advice would be useful.

Thank you.
Raymond.

On each button, eg:

on (release, keyPress "2") {
p.loadSound("lab/2.mp3", true);
}

Defined actions on separate controller layer, one of each sound, eg:

p = new Sound();

The button i used was:

on (release) {

p.stop();

}

But it stops everything. Thanks again.
Don't make 12 different sound objects! one is enough!
and by the way, change p to _root.p, and follow this tutorial

for the volume slider....
Make a horizontal bar about 40 pixels, and convert it into symbol. Make the instance name horizontal_bar. Then, make a vertical bar, and that's the one that's draggable. Convert it into symbol, and make its instance name slide_mc. Make sure the registeration point for both symbols is the center. Then, make a dynamic text field, and name it volume_txt. After that, paste this code into the frame:
var BEGINDRAG:Number = horizontal_bar._x - (horizontal_bar.width / 2);
var DRAGLENGTH:Number = horizontal_bar.width;
var DRAGY:Number = horizontal_bar._y;
var ENDDRAG:Number = horizontal_bar._x + (horizontal_bar.width / 2);
var INITIALVOLUME:Number = 100 //that's the default volume of music
var myMouse:Object = new Object();
_root.p = new Sound (this); //create a sound object

_root.p.setVolume(INITIALVOLUME);
slide_mc._x = BEGINDRAG + (INITIALVOLUME / 100) * DRAGLENGTH;
volume_txt.text = INITIALVOLUME + "%";
slide_mc.onPress = function()
{
this.startDrag(false, BEGINDRAG, DRAGY, ENDDRAG, DRAGY);
Mouse.addListener(myMouse);
}
slide_mc.onRelease = function()
{
this.stopDrag();
Mouse.removeListener(myMouse);
}
myMouse.onMouseMove = function()
{
var percent:Number = (_xmouse - BEGINDRAG) / DRAGLENGTH * 100;
_root.p.setVolume(percent);
slide_mc._x = _xmouse;
volume_txt.text = Math.round(percent)+ "%";
}