Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

mp3 restarting after a few seconds

 
Jump to:  
 
girlcharlie
PostPosted: Sat Aug 30, 2008 1:52 am    Post subject: mp3 restarting after a few seconds
       
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.



toggle_mc.stop();

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

//-----------


toggle_mc.onRollOver = function(){
var my_color:Color = new Color(toggle_mc);
my_color.setRGB(0xCF0000); // toggle_mc turns red
}

toggle_mc.onRollOut = function(){
var my_color:Color = new Color(toggle_mc);
my_color.setRGB(0x9A9997); // toggle_mc turns back to grey
}

toggle_mc.onRelease = function(){
if (this._currentframe == 1) {
this.gotoAndStop(2);
stopAllSounds();

music.loadSound("http://www.girlcharlie.com/test/music/ind/pianoLessons/jazzPi
anoLessons/09 Just One More Mile-DUPL_01 1.mp3", true);

} else {
this.gotoAndStop(1);
stopAllSounds();
}
}
 

 
girlcharlie
PostPosted: Sat Aug 30, 2008 4:35 am    Post subject: Re: mp3 restarting after a few seconds
       
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.
 

 
girlcharlie
PostPosted: Sat Aug 30, 2008 4:36 am    Post subject: Re: mp3 restarting after a few seconds
       
So ... any other thoughts? Smile
 

 
kglad
PostPosted: Sat Aug 30, 2008 9:20 pm    Post subject: Re: mp3 restarting after a few seconds
       
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.
 

 
girlcharlie
PostPosted: Tue Sep 02, 2008 7:59 pm    Post subject: Re: mp3 restarting after a few seconds
       
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.
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

Autopiloty anti spam conference call Bilety lotnicze Katowice wózki widłowe części