unmuteAllSounds
Lift the global mute. The master volume goes back to the value it had before muteAllSounds.
unmuteAllSounds(): void;
Parameters
This method takes no parameters.
Returns
Nothing.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSounds([
{ id: 'music', url: '/audio/theme.mp3' },
{ id: 'rain', url: '/audio/rain.mp3' },
]);
soundHub.play('music', { loop: true });
soundHub.play('rain', { loop: true });
soundHub.muteAllSounds();
soundHub.unmuteAllSounds();
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 restores the master gain. Buffered sounds you muted one by one with
mutestay muted. - Streams from
loadStreamare all unmuted withunmute, including a stream you had muted on its own. - It also lifts the mute that
autoMuteOnHiddenapplies when the page is hidden, and the silence left byfadeGlobalOutto0. - Dispatches
SoundEventsEnum.UNMUTE_GLOBAL('unmute_global') with the restored volume.
See also
muteAllSounds: silence everything.toggleGlobalMute: one call for a global mute button.setGlobalVolume: set the master volume directly.