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 soundHub.loadSounds([
{ id: 'tokyo-train', url: 'tokyo-train-melody.mp3' },
{ id: 'bells-melody', url: 'bells-melody.mp3' },
{ id: 'techno-tune', url: 'techno-tune.mp3' }
]);
soundHub.play('tokyo-train', { loop: true });
soundHub.play('bells-melody', { loop: true });
soundHub.play('techno-tune', { loop: true });
// Single button to toggle mute on/off
soundHub.toggleGlobalMute();
soundHub.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.