Skip to main content
Inspiring
August 30, 2008
Answered

mp3 restarting after a few seconds

  • August 30, 2008
  • 4 replies
  • 665 views
I have a site with a LOT of short mp3 music clips to play.
Currently what I built is working perfectly on my desktop,
but when I play it online, it glitches.
I assume there is a problem with the streaming somehow,
but I don't know where to start to fix it.

The glitches are:
(1) a song starts to play, then a couple seconds in, it skips and starts over then plays all the way through.
(2) sometimes if you click on a second song, when the second song skips (see glitch #1), the first song starts playing too so then they're both playing at the same time.

It's in AS2, btw.
The way it's currently built is I create a sound object
and use loadSound to load each external mp3 into that object.

There is a button for every song with a toggle switch inside the button.
The script to play the song is on every button.

(3) I do create the same sound object ("music") on every button.
Would it be better to create the sound object once on frame1 of the whole site
and have every song that loads from external .swfs reference that existing sound object?
Does it matter?

I am quite prepared to completely rebuild it if anyone has a better structure for how to do this.

You also may notice:
(4) I also have a problem with the toggle button (glitchy, but fixing the music is more important).
When you click on the second song, I can't figure out how to get the toggle on the first song
to revert to it's usual "play" state.

Thank you.

This topic has been closed for replies.
Correct answer omphaloskepsite
FIXED!

I put the code that creates the sound object on the first frame of the whole site.

var music:Sound = new Sound();
music.onLoad = function() {

Then, on each place within the site where I have a button to start the mp3, I
use loadSound into that "music" object created at the beginning.

No more skipping.
No more double playing.

4 replies

kglad
Community Expert
Community Expert
September 2, 2008
then you were re-entering the frame that contained that code.
kglad
Community Expert
Community Expert
August 30, 2008
i don't see a problem with that code unless you're re-entering the frame that contains that code or there's code elsewhere affecting "music". in particular, there should be no code/no sound on toggle_mc's timeline.
omphaloskepsiteAuthorCorrect answer
Inspiring
September 2, 2008
FIXED!

I put the code that creates the sound object on the first frame of the whole site.

var music:Sound = new Sound();
music.onLoad = function() {

Then, on each place within the site where I have a button to start the mp3, I
use loadSound into that "music" object created at the beginning.

No more skipping.
No more double playing.
Inspiring
August 30, 2008
So ... any other thoughts? :)
kglad
Community Expert
Community Expert
August 30, 2008
if you're going to stream your sound, there's no need to apply the start() method.
Inspiring
August 30, 2008
Thank you. I removed the start() method,
but it is still skipping and double-playing.
It doesn't do either at first, but after I click through a few songs on a page, it starts skipping and then double-playing.