Jump to content
Search Community

LoaderMax Restarting sound paused with timer

mark_vdi test
Moderator Tag

Recommended Posts

Hi to begin: wow the whole loader stuff and tweens stuff and . . . thanks!

 

I am am no jedi coder and therefore have some problem seeing passed what is probably a trivial problem - I load a sound using LoadMax mp3 loader (as part of multiple load) all is working fine I can access and play the whole sound (if i re-initialize: gotoSoundTime(0) took me a while to sort that one! - probably could do with being mentioned in the documentation) as many times as I need triggered by various coding events. The sound actually consists to 'two halves' so that sometimes I want to play both parts = full length, sometime only the first half and sometimes only the second half. To make this easier I buried the sound in three self explanatory function calls (the sound is ca. 2,6 secs in length): (soundBv is an MP3Loader)

public function soundFull():void {

soundBv.gotoSoundTime(0);

soundBv.soundPaused=false;

soundBv.playSound();

}

public function soundFirstHalf():void {

soundBv.gotoSoundTime(0);

soundBv.soundPaused=false;

soundBv.playSound();

var timer:Timer = new Timer(1300,1);

function timerListener (e:TimerEvent):void {

soundBv.soundPaused=true; // I get the same effect If I use soundBv.pauseSound();

}

timer.addEventListener(TimerEvent.TIMER, timerListener);

timer.start();

}

public function soundSecondHalf():void {

soundBv.soundPaused=false;

soundBv.gotoSoundTime(1.30, true);

}

However: after calling soundFirstHalf which plays the first half of the sound as required no matter what i do I cannot get the sound to replay when I call soundFull or soundSecondHalf afterwards. (This doesn't matter whether I call pauseSound or use soundPaused=true;) I can in contrast call soundSecondHalf as many times as I want without problem as long as the soundFirstHalf has not been called. [As far as I can tell from the documentation setting soundPaused=false shouldn't actually be needed anyway.] The solution I'm sure is very trivial but a nudge in the right direction would be very helpful.

Thanks Mark

Link to comment
Share on other sites

i don't see anything jumping out at me. the only thing I would do to clean it up would be to not nest the timerListener function inside soundFirstHalf. putting functions inside functions is considered bad form, i'm not so sure this has any effect on the issue though. it looks like it should work.

 

if you post a zip of a simplified fla with your mp3 that has 3 buttons set up that illustrate this bug I'll give it a look. the file should be as simplified as possible to only illustrate the behavior you are experiencing. thanks

 

if you don't feel like doing that I would suggest adding some traces to soundSecondHalf like:

 

trace(soundBv.soundPaused);

trace(soundBv.currentTime);

 

to get an idea of what is happening with soundBv after soundFirstHalf has done its business.

 

Carl

Link to comment
Share on other sites

Hi Carl,

 

thanks for having a look after several frustrating hours I finally worked out that, as usual, the weakest link in the chain is the one typing into the keyboard and can only apologies for wasting your time. I used all the traces I could think of for all the properties of soundBv as specified for the MP3Loader to make sure that soundSecondHalf was still pointing to an 'intact' soundfile etc. and also that soundFirstHalf was moving and leaving the pointer at the right place (playProgress, channel, etc etc.) + for all timing events and triggers and everything looked frustratingly ok - interestingly there was some a difference between the Timers version of 1,3 secs. and a TweenMaxs version of 1,3 secs. Thus although soundSecondHalf was separated from soundFirstHalf by loading events checked by onComplete calls at the end of a Tween (1,3 secs away from the start of soundFirstHalf that was paused after 1,3 secs.) locally where the loads were almost instantly available the soundSecondHalf was being triggered miliseconds before the pause command in soundFirstHalf . . . as it turns out effectively killing the playback of soundSecondHalf.

 

Thanks again for checking, Mark

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...