# Audio

Let your game mute and unmute through the Wavedash SDK

Source: https://docs.wavedash.com/sdk/audio

Wavedash owns the mute control so its player-facing mute button and your game stay in sync. Your game **requests** a mute change through the SDK; Wavedash applies it and broadcasts the new state back to every game on the page.

<Tip>
Wavedash already exposes a player-facing mute button on every game page and handles muting/unmuting your audio automatically, so most games don't need to call these methods at all. Reach for `requestMute` / `toggleMute` only when you want an in-game control (e.g. an options-menu toggle or a speaker icon the player can click).
</Tip>

## Muting and unmuting

Call `requestMute(true)` to mute and `requestMute(false)` to unmute. `toggleMute()` flips whichever state you're in.

<CodeGroup>
```gdscript Godot
func _on_mute_button_pressed():
    var applied = await WavedashSDK.toggle_mute()
    if not applied:
        show_player_muted_hint()
```

```csharp Unity
public async void OnMuteButtonClicked()
{
    bool applied = await Wavedash.SDK.ToggleMute();
    if (!applied) ShowPlayerMutedHint();
}
```

```javascript JavaScript
muteButton.addEventListener("click", async () => {
  const applied = await Wavedash.toggleMute();
  if (!applied) showPlayerMutedHint();
});
```
</CodeGroup>

Both `requestMute` and `toggleMute` resolve to `true` if the host applied the change, `false` if it was rejected.

<Note>
**Player mutes win.** When a player mutes the game from the Wavedash UI, your game **cannot** unmute over that — `requestMute(false)` (and the unmute half of `toggleMute()`) resolves to `false` and the game stays muted. This prevents a game from fighting the player's explicit choice. Muting always succeeds, and the game can freely unmute a mute it set itself.
</Note>

Unlike fullscreen, muting has no user-gesture requirement, so you can call these methods from anywhere — including timers and async callbacks.

## Checking state

`isMuted()` returns the current state, mirrored from the Wavedash host page.

<CodeGroup>
```gdscript Godot
if WavedashSDK.is_muted():
    speaker_icon.set_muted(true)
```

```csharp Unity
if (Wavedash.SDK.IsMuted())
    speakerIcon.SetMuted(true);
```

```javascript JavaScript
if (Wavedash.isMuted()) {
  speakerIcon.setMuted(true);
}
```
</CodeGroup>

## Reacting to mute changes

State can change from the player's Wavedash mute button as well as your own calls, so subscribe to the mute-changed event to keep any in-game UI in sync — the payload carries `isMuted`.

<CodeGroup>
```gdscript Godot
WavedashSDK.mute_changed.connect(_on_mute_changed)

func _on_mute_changed(payload):
    speaker_icon.set_muted(payload.isMuted)
```

```csharp Unity
Wavedash.SDK.OnMuteChanged += payload => {
    speakerIcon.SetMuted((bool)payload["isMuted"]);
};
```

```javascript JavaScript
Wavedash.on(Wavedash.Events.MUTE_CHANGED, (payload) => {
  speakerIcon.setMuted(payload.isMuted);
});
```
</CodeGroup>
