Streaming mp3 files?

I can’t believe I had to register again?? What gives? I couldn’t log in.

Oh well, here’s my question. I’m working on a fully flash website. I want to stream a few mp3’s from the server instead of having them in my main swf.

I haven’t been able to find a decent tutorial on this. My new book on flash doesn’t even go into enough detail. I want to know how to stream the files ( there are 3 of them). Let the user choose between the files via buttons. And stop and play buttons for the files as well.

Can someone please help me?

I use a similar technique as this on one of my sites. It’s pretty
much what you need to get started, I’m sure.

http://www.flashkit.com/tutorials/Audio/Create_c-Shaun_St-881/index.php

I’m a little confused with the tutorial you refered me to.

so here’s the code he says to use in the main timeline
I don’t have a domain name yet. What do I put in the field where the URL is?? I would like to be able to test this to make sure it works before I post the site.

Also when creating the external swf with all the music files, does it matter what I name the swf? This also isn’t mentioned in the tutorial. :frowning:

stop();
unloadMovieNum(66);
loadMovieNum(“http://www.yoursite.com/swf/song1.swf”, 66);

ok…

the path to the file can be wherever it’s located. In most cases,
you’re going to want to just keep it in the same directory as your
main movie, or in another folder named music or something. You
don’t necessarily need to list out the entire URL.

So, could look like this:

stop();
unloadMovieNum(66);
loadMovieNum("music/song1.swf", 66);

or even simpler, this:

stop();
unloadMovieNum(66);
loadMovieNum("song1.swf", 66);

If you use the 2nd method, just make sure the music movie is in
the same directory as your main movie.

As for the naming, it does not matter at all what you name them.
Just so long as they are the same. So if the file is named
hotmusic1.swf, then make sure the code reflects that.

thanks for the help. You website is awesome by the way!!

np - and thx :slight_smile:

im a little confused is this how to stream a song meaning it plays as you download it, or is this how you load it like on electron geeks site, i would prefer that version if somone could point me to it

On your music swf file just add a preloader actionscript on it’s .fla file. :slight_smile:

it’s the same thing as electrongeek’s site. It’s actually playing as
it’s loading. Just set your audio export settings to stream, and
away you go!

If you want them to have to download the entire song first, then
you would want to add a preloader like lairusi suggests.

:slight_smile:

but how do you get the loader to go in a certain spot… and hwo to you get the bars to start popping once the sound comes up :confused:

getting the loader to go is just following the basic preloader rules.

the lines are just a mc he made to designate that the sound is
playing. Simply load the lines mc on the first frame of the sound,
beyond the preloader.

OK. I followed the tutorial and then ran the movie. The first song did start playing like it should. The stop button worked as well. But the play button didn’t work after I stopped it. I also got these errors. Please help.

Scene=Scene 1, Layer=buttons, Frame=80: Line 3: String literal was not properly terminated
loadMovieNum("song1.swf, 66);

Scene=Scene 1, Layer=buttons, Frame=80: Line 4: ‘)’ or ‘,’ expected
}

Scene=Scene 1, Layer=buttons, Frame=80: Line 1: Statement block must be terminated by ‘}’
on (release) {

Scene=Scene 1, Layer=buttons, Frame=80: Line 5: Syntax error.

Scene=Scene 1, Layer=buttons, Frame=80: Line 3: String literal was not properly terminated
loadMovieNum("song2.swf, 66);

Scene=Scene 1, Layer=buttons, Frame=80: Line 4: ‘)’ or ‘,’ expected
}

Scene=Scene 1, Layer=buttons, Frame=80: Line 1: Statement block must be terminated by ‘}’
on (release) {

Scene=Scene 1, Layer=buttons, Frame=80: Line 5: Syntax error.

Scene=Scene 1, Layer=buttons, Frame=80: Line 3: String literal was not properly terminated
loadMovieNum("song3.swf, 66);

Scene=Scene 1, Layer=buttons, Frame=80: Line 4: ‘)’ or ‘,’ expected
}

Scene=Scene 1, Layer=buttons, Frame=80: Line 1: Statement block must be terminated by ‘}’
on (release) {

Scene=Scene 1, Layer=buttons, Frame=80: Line 5: Syntax error.

LOL never mind!! I went over the code again. I was missing end quotes. Bah!!

glad you caught it, cuz I was just about to tell you! hehe

glad it worked for you, and nice job finding it yourself. not many
keep trying once they post here.

=)

k i followed the tutorial… ig ot it to wokr… http://tek-labs.com/songtext.swf it all works fine… and i udnerstnad putting the little music bars after the preloader, but i dont get how they come up in an exact spot on the songtext.swf… please help

anyone?

there’s a couple ways to go about this, but here’s the easiest IMO…

Make your bars it’s own movie, not movie clip - it’s own movie.
Make it the same size as songtext.swf, and place your animations
in the appropriate spot in relation to songtext.swf.

Then, after your preloader, put this code:

loadMovie("bars.swf", "10");

the “10” represents a level, so you can use whatever level
necessary to fit your project. “bars.swf” obviosuly is the name of
whatever your bars movie is.

Give that a try…

i THINK i understand… so i have to make a seperate movie clip for the song and a sepereate one for the bars… what if i want there to be a loading bar, like on electrons site and i want the bar to show up inside the box, then i want the bars to start playing after the song is loaded… any thoughts? and thanks

not movie clips, MOVIES. totally seperate new movie for the bars.

The loading shows up in your preloader for the sound, then load
the bars.swf movie after it’s complete. understand?

so basically im loading 2 seperate movies at once… and i think i understand how to get the sound bars to appear, but theere are 2 problesm

how do i get the music loader to show up in the box

how do i get the black bars to appear AFTER the loader, and right when the music plays