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
Mute everything at once
Idletokyo-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
unmuteAllSoundswhen the hub is globally muted andmuteAllSoundsotherwise, with their events. - A
fadeGlobalOutthat ends at0counts as muted, so the next toggle brings the volume back. - Muting single sounds with
mutedoes not affect the choice.
See also
muteAllSounds: silence everything.unmuteAllSounds: bring it back.toggleMute: the same for one sound.