Skip to main content

toggleGlobalMute

Mute everything when the mix is audible, and unmute it when it is muted. One call for a global mute button.

toggleGlobalMute(): void;

Parameters​

This method takes no parameters.

Returns​

Nothing.

Example​

import { SoundHub } from 'soundhub';

const soundHub = new SoundHub();
await soundHub.loadSound('music', '/audio/theme.mp3');

soundHub.play('music', { loop: true });

muteAllButton.addEventListener('click', () => {
soundHub.toggleGlobalMute();
});

Try it​

Try it

Mute everything at once

Idle
tokyo-trainstopped
bells-melodystopped
techno-tunestopped
Masteraudible

The three sounds keep playing while muted. Only the master output goes silent.

Code
Your clicks show up here as soundhub calls

Good to know​

  • It calls unmuteAllSounds when the hub is globally muted and muteAllSounds otherwise, with their events.
  • A fadeGlobalOut that ends at 0 counts as muted, so the next toggle brings the volume back.
  • Muting single sounds with mute does not affect the choice.

See also​