all groups > flash actionscript > may 2004 >
You're in the

flash actionscript

group:

Multiple Mp3 player



Multiple Mp3 player gbhumphrey
5/22/2004 6:15:43 PM
flash actionscript: Does anyone know a good tutorial for a Multiple MP3 player? I can make a player that plays one Mp3, but cant seem to figure out how to alter the code to allow for multiple sound objects.
Re: Multiple Mp3 player B
5/22/2004 6:47:59 PM
create an array with the identifier names of the songs that are in your
library. (set the identifier name of the song by right clicking on the song in
the library, choosing linkage, check the export for actionscript and export in
first frame checkboxes, then give it a unique name in the identifier text box)

Here's an array with three songs:
<!--Begin actionscript-->
songArray = ["soulLoop", "grooveLoop", "fastBeat"] //the items in the array
are the indentifiear names
mySound = new Sound( ); //set a variable to the Sound object

soulButton.onRelease = function ( ) {
stopAllSounds();//stops any other song that may be playing
whichOne = songArray[0];
mySound.attachSound(whichOne);
mySound.start(0);
mySound.onSoundComplete = function( ) {
mySound.start(0); //the line above and this line replays the song when it
finishes its first loop
}
}

grooveButton.onRelease = function ( ) {
stopAllSounds( );
whichOne = songArray[1];
mySound.attachSound(whichOne);
mySound.start(0);
mySound.onSoundComplete = function( ) {
mySound.start(0);
}
}

beatButton.onRelease = function ( ) {
stopAllSounds( );
whichOne = songArray[2];
mySound.attachSound(whichOne);
mySound.start(0);
mySound.onSoundComplete = function( ) {
mySound.start(0);
}
}
<!--End actionscript-->
FYI soulButton, grooveButton, and beatButton are the names of the buttons on
stage.
Re: Multiple Mp3 player waveturtle
5/22/2004 7:55:03 PM
what if you want to load the mp3s dynamically? The problem I'm having is with
my pause/play buttons. Since I only have 1 soundobject and each song is loaded
into the same sound object, the position property doesn't reset between songs
and thus my pause function (var pauseTime = mySound.position) works
incorrectly.

Any ideas?

Rob
Re: Multiple Mp3 player Jack.
5/22/2004 8:17:27 PM
for play/pause, can you make use of the code / logic in this file ?
http://www.jackleaman.co.uk/mp3_php_jukebox.html

a good tutorial on the sound object -
Re: Multiple Mp3 player gbhumphrey
5/22/2004 9:34:44 PM
Re: Multiple Mp3 player B
5/22/2004 11:07:07 PM
I tried to attach an fla file that should help you, but for some reason I can't
get it to attach to this reply. If you post your email address I will email it
to you.

Instead of using the attachSound method that you'll see in the script (once
I've emailed the file to you), use loadSound("http://serverpath/file.mp3",
streaming?)

Streaming needs to equal true or false.

If it's false, I believe you will need to attach the sound object variable to
the beginning of loadSound (ie:
mySound = new Sound ( )'
mySound.loadSound("http://serverpath/file.mp3", false)

Otherwise it will just look like this:
loadSound("http://serverpath/file.mp3", true)

Use this in place of where you see the attachSound method in my fla file. And
of course you'll no longer need the array or the variable that grabs the
identifier name out of the array.

Hope this helps!!

Brenda
Re: Multiple Mp3 player waveturtle
5/22/2004 11:27:04 PM
mySound.loadSound can be either "event" (does not play until the file is
completely loaded) or "streaming" (plays as soon as enough data loads to begin
playing).

true = streaming
false = event

if you use false (event), you need to tell Flash to start playing that sound
after it loads, so the script would be

mySound.loadSound("the sound's URL" , false);
mySound.onLoad = function() {
mySound.start(0, 1);
}

cheers,
Rob
Re: Multiple Mp3 player gbhumphrey
5/23/2004 7:49:06 AM
Re: Multiple Mp3 player gbhumphrey
5/23/2004 7:50:49 AM
AddThis Social Bookmark Button