Skip to main content

toggleGlobalMute

toggleGlobalMute(): void;

Toggle the global mute state for all sounds. If sounds are muted, they become unmuted and vice versa. This is a convenience method that avoids needing to check the current state before calling muteAllSounds or unmuteAllSounds.


Example

await soundManager.loadSounds([
{ id: 'tokyo-train', url: 'tokyo-train-melody.mp3' },
{ id: 'bells-melody', url: 'bells-melody.mp3' },
{ id: 'techno-tune', url: 'techno-tune.mp3' }
]);

soundManager.play('tokyo-train', { loop: true });
soundManager.play('bells-melody', { loop: true });
soundManager.play('techno-tune', { loop: true });

// Single button to toggle mute on/off
soundManager.toggleGlobalMute();
soundManager.toggleGlobalMute();
🔇 Press "Play All" to start
Try it: Play three sounds together, then use Mute All / Unmute All to toggle all sounds at once. toggleGlobalMute switches between muted and unmuted — useful for a single master mute button.