I’ve been contacted over the past few weeks on several occasions regarding the use of sound and the sound object within Flash, and strangely enough, the same question keeps on coming up; “How do I pause and then resume sound?
Another way, since position stays the same when you stop a sound, is to just start and stop it:
my_sound = new Sound(this);
my_sound.start(my_sound.position / 1000);
Awhile back I built a FlashMX-based MP3 player that streams MP3’s. I didn’t build in pause functionality because I didn’t see it used in streaming-based players online. However, I’ve started the process for implementing my player in AS2. Along with that upgrade I thought about putting in a pause button. I haven’t attempted it yet, but I think I did read somewhere that pausing streaming media wasn’t possible in Flash. I’ve written a few dozen components that have pause controls for event-based sounds so adding the code won’t be hard, but as yet I can’t say whether it will work or not.
I’ve tried this script in Flash MX 2004, tho I can seem to get it to work. Is there a special way to get it to work in MX 2004, or is it just not possible?
[PS im relitavely new to Flash, tho am learning quick, so plz, not to complicated]
Just so people know, pausing is possible in new versions of the flash player using the stop() and start() methods. however, if you do this your sounds won’t play at all if the user has an older version — If anyone has ideas about how to check if this pausing works (or a list of the flash player versions that fail), please post them here.
Streaming audio can be paused in Flash MX. All you have to do is create a movie clip, then within a layer of the movie clip (to do this, double click on your newly created movie clip), you simply load the movie in from your library. Make sure you Sync the audio to stream. Then return to your main stage, create the pause and play buttons. To pause:
note: the above code will pause flash audio, the flash timeline and an external swf. To only pause the flash audio, simply remove all lines of code that contain the word “_root”.
host – Instance name of movie clip for external swf to load onto
mymovie – Instance name of movie clip which audio loads into
One final note about this. Streaming audio is the worst quality of audio flash offers. If you are making a demo I suggest that you use the code given at the top of this page and keep your audio sync as normal.
Thanks a lot for the code at the top of this page, it worked like a charm for me :).
i think people want to know how to pause the external .mp3, not another .swf.
what about making the control a single button
There’s one problem with your example, you can continuously push play to have alot of versions of the same unsynchronized mp3s playing at the same time.
It would be practical for the play button to detect that the mp3 is playing and disallow overdubbing. If you have the scripting for this, I would really appreciate to view it.
Right, I know this thread has been left for quite a while, but just for the reference of google-ers, there is a solution to the problem Mathieu has highlighted…
Go to the frame properties (window>properties) over which the sound is placed. Under the sound properties> sync selection select stream from the drop-down box. It should now only play one instance of that clip.
Oh yeah, provided you have flash cs5. Not sure how well it goes on other versions.
I have multiple movie clips with different sounds in each movie.
My movie clips are placed across the main timeline of my movie.
I have a “Next” and “Back” button on the main timeline that jumps me from frame to frame where each movie clip is placed. Everything works great…..but my sounds from the movie clips are running together.
How do I stop all sounds in a movie clip from the main timeline when I click either the “Next” or “Back” button.
I have a background sound on the main timeline and I do not want to stop this sound…….so the StopAllSounds function is not working for me. I just want to stop the sounds in the Movie Clip when I click the “Next” button.