Search documentation

Find pages, sections, and content across all docs.

WavedashDocs

Audio

Let your game mute and unmute through the Wavedash SDK

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.

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).

Muting and unmuting

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

func _on_mute_button_pressed():
    var applied = await WavedashSDK.toggle_mute()
    if not applied:
        show_player_muted_hint()
public async void OnMuteButtonClicked()
{
    bool applied = await Wavedash.SDK.ToggleMute();
    if (!applied) ShowPlayerMutedHint();
}
muteButton.addEventListener("click", async () => {
  const applied = await Wavedash.toggleMute();
  if (!applied) showPlayerMutedHint();
});

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

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.

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.

if WavedashSDK.is_muted():
    speaker_icon.set_muted(true)
if (Wavedash.SDK.IsMuted())
    speakerIcon.SetMuted(true);
if (Wavedash.isMuted()) {
  speakerIcon.setMuted(true);
}

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.

WavedashSDK.mute_changed.connect(_on_mute_changed)

func _on_mute_changed(payload):
    speaker_icon.set_muted(payload.isMuted)
Wavedash.SDK.OnMuteChanged += payload => {
    speakerIcon.SetMuted((bool)payload["isMuted"]);
};
Wavedash.on(Wavedash.Events.MUTE_CHANGED, (payload) => {
  speakerIcon.setMuted(payload.isMuted);
});