2 Replies Latest reply on Feb 27, 2008 9:12 AM by ooba

    New to sound file usage.

    ooba Level 1
      How do i detect if a file is actually playing in order to prevent starting the playing of the file again and having an audible overlap of audio?
        • 1. Re: New to sound file usage.
          i_am_captivate Level 1
          Hmmm......

          So when you say "file" I take it you are referring to a "sound file" correct?

          Let's say you have a sound file called "cool.mp3", and you have the linkage set up so it's called "cool".

          var newSound = Sound();
          newSound.attachSound("cool");
          newSound.start();

          Now the sound is playing. Generally what I do (there may be a better way), is use stopAllSounds(); when I want to make sure there is no audio overlapping. So back to our example, if you wanted "cool" to stop playing on say, when a button gets clicked, you could do something like the following,

          myButton.onPress = function(){
          stopAllSounds();
          }

          Or if you want to execute code when "cool" is done playing, like go to the next frame, you could use

          var newSound = Sound();
          newSound.attachSound("cool");
          newSound.start();
          newSound.onSoundComplete = function(){
          nextFrame();
          }

          I hope this helps point you in the right direction in what you are looking for

          Doug
          • 2. Re: New to sound file usage.
            ooba Level 1
            imjustabeginner thanks for the response, but the issue that i was having dealt with an audio file that I want to keep playing on a loop but under a certain situation another file may or may not be playing and I need to detect if it is playing prior to starting the loop file.

            Another part of the issue seems to be that the player had cached the swf and was not refreshing. Man I hate when this occurs.