PDA

View Full Version : Help: Loop externally loaded mp3



strik3r
November 3rd, 2005, 04:25 AM
Ok, I've used this syntax to load an external mp3 into my movie

mySoundObject=new Sound();
mySoundObject.setVolume(100);
mySoundObject.loadSound("podloga.mp3",true)

when I add this at the end, to make the sound loop - it has no effect

mySoundObject.start(0,999);

What am I doing wrong?

bzouchir
January 25th, 2006, 05:37 AM
You're MP3 is streaming so it starts playing whenever it has enough data to play without waiting for the whole mp3 to load.

Therefore mySoundObject.start(0,999); won't do anything!
It's for attached sounds using Actionscript.

Check out this link it explains it all!

http://kennybellew.cowfly.com/tutorial/dynamically.htm

and this one is a tutorial on how to do it with ActionScript:

http://www.actionscript.org/tutorials/intermediate/sounds_and_preloaders/index.shtml

hope that will help!

cheers

marathon_ben
January 30th, 2006, 02:18 PM
I'm modifying a component I found at flashcomponents.net so that the sound file is loaded dynamically. It works, except the file doesn't loop.

I understand the why, but I need to know the how: how do I get it to both load dynamically and loop. I read through both of those tutorials, but neither helped in this case.


#initclip
function sound_faderClass() {
this.sound_fade = 100;
this.Soundan = 1;
this.theSound = this.fsound;
//
this.sound1 = new Sound();
this.sound1.loadSound("assets/music.mp3", true);
//

}
//
sound_faderClass.prototype.fadeout = function() {
if (this.sound_fade>0) {
this.sound_fade -= this.fout;
} else {
this.sound_fade = 0;
}
this.sound1.setVolume(this.sound_fade);
};
// /////////////////////
sound_faderClass.prototype.fadein = function() {
if (this.sound_fade<100) {
this.sound_fade += this.fin;
this.sound1.setVolume(this.sound_fade);
}
};
// //////////////////////////
sound_faderClass.prototype.start_sound1 = function() {
this.Soundan = 1;
//this.sound1.setVolume(100);
this.sound1.start(0, 100);
};
// //////////////////////////////
sound_faderClass.prototype.stop_sound1 = function() {
this.sound1.setVolume(0);
this.sound1.stop();
};
// ///////////////////////////////////

// //////////////////////////
Object.registerClass("sound_fader", sound_faderClass);
#endinitclip
//
this.onEnterFrame = function() {
if (this.Soundan == 1) {
this.fadein();
}
if (this.Soundan == 0) {
this.fadeout();
}
};

this.start_sound1();

Am I close?

marathon_ben
January 31st, 2006, 08:38 AM
Apparantly if you wait a day, things just magically start working.

I added

this.sound1.onSoundComplete=function () {
this.start(0, 999);
} directly after the load sound, ( which I could've sworn I tried yesterday) and it works.

If anyone's interested in it, I can post the fla. Or I was thinking of using an xml file to locate the mp3, that way I could have a cms handle assigning the music. Thoughts?

marathon_ben
February 10th, 2006, 08:50 AM
Any help on how to use a dynamic xml file with this? Most tutorials I've found are either too complex. I don't want a playlist, next/back button, array, or anything else. I just want to declare the mp3 in an xml file and name the xml file from the html embed.

Thanks!