Mute music- On music

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nick888

When i start my game, at the same time starts and the music.I have created a button that if someone press it ,i want the music stop and if press it again i want the music starts. If i send a signal from button to AudioStreamPlayer node ιs there a specific code to stop and play the music again?

I thought something like that in general:

func _on_Button_pressed():
get_tree().<= not get_tree().


Thank you.

I thought something like that in general:

func _on_Button_pressed():
get_tree().playmusic= not get_tree().playmusic


Nick888 | 2019-06-05 08:30

:bust_in_silhouette: Reply From: Dlean Jeans

This will toggle the first audio bus:

AudioServer.set_bus_mute(0, not AudioServer.is_bus_mute(0))

You might wanna create a separate audio bus for sound effects, for example.
More info on Audio Buses.

Thank you very very much!!!

Nick888 | 2019-06-05 09:22