0 votes

I want to create a button that enable / disable sounds. How to do this? The question is not a button, but, about the method on AudioStreamPlayer2D.


in Engine by (17 points)

2 Answers

+1 vote
Best answer

yep, as ConnyOnny said, you can use this to mute your sound : (it's going to stop it though, not just mute it)

get_node("yourAudioStreamPlayer").playing = false

this to mute all sounds :

AudioServer.set_bus_mute(AudioServer.get_bus_index("Master"), true)   

or this to mute all sounds from a specific audio bus :

AudioServer.set_bus_mute(AudioServer.get_bus_index("specificbus"), true)   
by (245 points)
selected by


AudioServer.setbusmute(AudioServer.getbusindex("Master"), true)

Using this:

get_node("yourAudioStreamPlayer").playing = false

Causes the sound to play when setting to: true. So I am not sure it is a good way of muting sound..

0 votes

According to the documentation there is a member variable playing. You can try to set it to false.

If that doesn't work you can add a script to the player node and add a method pause and resume where you store the value fromget_plaback_position in your own member variable and stop the playback and on resume you can use the play method with the old playback position as parameter, so it starts at that point.

by (47 points)

Thank you, but this does not work.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.