PDA

View Full Version : streaming mp3's causes slow animation


thpii
09-21-2002, 03:52 PM
I tried this technique which I learned from www.superhere.net (which by the way has a nice working example of what I'm trying to do)

I'm trying to stream MP3s (like an internet radio) using the following technique:

--------
open a new fla, import the mp3 file. Place the audio in the timeline. Set the sync to stream in the sound properties bar. Enlarge the timeline to fit the mp3. Change the mp3 stream compression in the publish settings, I use MONO 80kbps. Export the swf, I will refer to this as mytrack.swf. Now open a new fla, Create a new empty movieclip and place it in the scene with an instance name of container. Touch the first frame of the main timeline. Open the frame actions panel and write:

loadMovie("mytrack.swf", "container")
--------

The problem is that while the audio is playing, it brings the animation on my site to a crawl. How do I get around this? The example above (www.superhere.net) doesn't have this problem...

Any ideas?

-Theron

thpii
09-21-2002, 09:31 PM
After some investigation and some trial & error, I think it's better to just use:

s = new Sound();
s.loadSound("name_of_song.mp3", true); // true makes it stream

This method doesn't degrade the animation.... and I have full control over my sounds, including stop/start/pause/pan and volume, so with some buttons you can easily create your own mp3 player in flash.... Pretty cool.

-Theron

koncadu
09-25-2002, 08:45 PM
Theron,

would you share more about how to do this? Your idea seems better in that you can access straight mp3 files instead of having to make them into swf movies.

Thanks.

-Dusko

thpii
09-26-2002, 01:47 AM
Sure,

I actually created an mp3 player in flash using this method....

here are the button actions:
//pause button
on (release) {
//Pause Button
if (pause!=true) {
playing=false;
paused=true;
stopped=false
myConditionText="Paused";
myMusicPosition=s.position/1000;
s.stop();
}
}

//play button
on (release) {
//Play button.
//Sound is not playing and has not been paused
if (playing!=true) {
if (paused!=true) {
playing=true;
paused=false;
stopped=false;
myConditionText="Playing";
s.start(0,0);
}
//Sound has been paused
if (paused==true) {
playing=true;
paused=false;
stopped=false
s.start(myMusicPosition,0);
myConditionText="Playing";
s.onSoundComplete = function() {
s.start();
}
}
}
}

//stop button
on (press) {
//Stop Button
playing=false;
paused=false;
stopped=true;
myConditionText="Stopped";
s.stop();
myMusicPosition=0;
myMusicPositionText=0
}


//previous button
on(release) {
s.stop();
prevFrame();
}

//next button
on(release) {
s.stop();
nextFrame();
}

Say you want to have 20 mp3s, just create 20 keyframes, each that look something like this:

s = new Sound();
s.loadSound("mp3/self_destructing.mp3", true);
currentTrack="Self Destructing";
stopped=false;
paused=false;
stop();

If you want to see it in action go here:

http://www.theronparlin.com/thpii.html

if it's not there anymore (i.e. I launched the site), go here:

http://www.theronparlin.com

spriggan
10-10-2002, 11:59 PM
I've been trying to figure out something like this for a while. Nice job. Anyway I tried your script and I cannot get it to work. I think it has to do with the loadSound() function. It that one you made yourself? I can't find any online refrence for it at macromedia.

spriggan
10-11-2002, 12:38 AM
umm ok I guess that's it Flash MX only. Dang, I'll just have to live with attachsound

thpii
10-11-2002, 02:24 PM
No I didn't create it... It might be a MX only thing, not sure. Sorry about that... :(