Stop tagged audio from playing?

0 favourites
  • 10 posts
From the Asset Store
This Student Workbook uses both Construct 3 & 2 encoding. It supplies client-side & php "back-end" encoding.
  • I want to press a button and stop all audio tagged "FX" from playing. Whether it's playing at the time or going to be played in the future. I tried the muted event, but the sounds keep on playing.

    Should that do it or is there another way? Thanks.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This is for Chrome (latest versions always), as it seems to have the best support for HTML5 audio right now.

    First, click on the audio plugin in the project folder window. Make sure on the left that audio timescale is turned on.

    Also, it seems to depend on which folder you use for audio. If you put it in the "music" folder, then audio will pause correctly when timescale is "0". If audio is in the "sounds" folder, this doesn't work for some reason.

    If you tell any audio to stop when a certain button is pressed (e.g. On Keyboard Button 'A' pressed, Stop audio), that should work. It works just fine for me. If you tell it to mute (like for looping ambient sounds), that should work too.

    Like I said, make sure you have the audio timescale turned on. Play around with the 2 different settings ("sounds" and "sounds and music").

    In Chrome I've managed to get most things to work properly.

  • Thanks ptbcomposer I'll give it a go and let you know.

  • ptbcomposer I set timescale to ON and moved the sound in to the music folder but still no joy.

    Further tests show that the "mute button" works when the FX sound is playing at the time.

    So, it's muting the sound but not stopping it from playing. Is there a command that disables a sound from playing in the future?

  • No, no, no...you have to use the "Stop Playback" event. Of course the sound is still playing when you mute it. Think of this like you're watching a recording on TV. You press mute, but playback is still happening. You just can't hear it. On the other hand, if you hit stop, then playback stops. Look at my response to this post...

    http://www.scirra.com/forum/topic53670.html

  • Sorry, I forgot to answer the other question...no, I don't think there is any way to prevent a sound from playing. The only way I can think of is to disable it yourself on the event sheet. Why would you want to do that anyway? If you don't want the sound to play, don't have an event for it.

  • It's a "disable sound effects" button. If the player doesn't want to hear effects, they can press the button (once) to silence them. I tried your answer in the other thread but it didn't act any different.

    I'm going to try this plugin. Thanks for your help.

    scirra.com/forum/plugin-appmobi-plugin-updates_topic55572.html

  • Check this out. Make sure every sound you want to mute is tagged with the same tag (in my case it is "sfx"). Create a global variable called "SFXAudio" or "SFXMute" whatever and then follow this code...

    <img src="http://wayofthesax.com/img/mute%20button%20screenshot.png" border="0" />

    When global variable is 0, "sfx" is muted. When global variable is 1, "sfx" is unmuted. Simple. For some reason Construct 2 buttons don't work with it, so use your own as a sprite or something (in my case here it is a text box).

  • I didn't know that's what you were trying to do. Sorry.

    Also, you can use that for anything you want to mute, such as ambient sounds and music. Just remember to tag everything correctly, and create a global variable for them.

  • Oh, and I just tried. This works even when switching between browser tabs.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)