Mute Sound for app?

Is there a way to mute sound (i’m using the filename.Play commands for playing sound) just for your app? Some users want to turn the music/sound off for my game. Thanks!

Don’t execute the PLAY commands?

Well, since I have Play commands throughout the app, it might be efficient to mute the app sound rather than going through each instance and inserting code to see if a user has chosen to mute.

Why don’t you just check to see if the sound in question is playing, and if so, stop it, or set the volume to 0??

For example, if the main game sound is called bgSound, have a button called mute, which when depressed, checks to see if bgSound is playing, if so, stop it.

Mute Button Code:

if bgSound.IsPlaying then bgSound.stop end if

Alternatively have the button as a toggle button, with the following code:

If bgSound Isplaying = false then bgSound.Play else bgSound.stop end if

I did find the Sound.Volume command, but does that affect just your app’s sound, or the whole system?

bgSound.volume = 0

Should* only mute the volume for that particular sound.

Thanks, Richard…yes I know about IsPlaying and all of that…I was looking for an easy way to mute the sound throughout an entire app. Is there a simple way to do this?

This should* do exactly what you need:

If bgSound.volume = 0 then bgSound.volume = 100 else bgSound.volume = 0 end if

Let me know if it worked for you.

Thanks, Richard…yes I know about IsPlaying and all of that…I was looking for an easy way to mute the sound throughout an entire app. Is there a simple way to do this?

Do you want to mute ONE sound which is in your app - or ALL of them??

If you only want to mute a single sound, the code I gave you above will do that.

If you want to mute ALL sounds in YOUR app, then just use the code I gave you above, and add the additional sound files, such as:

// Check if ANY of your app's sounds are muted If bgSound.volume = 0 then // Re-set the volume of the following sounds to 100% bgSound.volume = 100 bgSound2.volume = 100 else // Mute the following sounds bgSound.volume = 0 bgSound2.volume = 0 end if

As far as I know - there is no universal way of muting the sound of an entire app??
(I could be wrong though) :slight_smile:

search & replace

find

sound.play

and replace it with

if not soundsDisabled then sounds.play

Bruce - just out of curiosity, where in the language reference is soundsDisabled??

It would be a variable Derek declared, it’s not in the LR.

Ahhh - you mean create a property called soundsDisabled As Boolean, and then set it to true if the mute button is pressed.

Correct

Create a function or subclass that wraps the play with the same syntax, and use a global replace to substitute all the calls you make to play in your app. Then you can mute in the master class or the function.