unmute
Bring a muted sound back to the volume it had before mute.
unmute(id: string): void;
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | required | ID of the sound or stream to unmute. |
Returns
Nothing.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSound('music', '/audio/theme.mp3');
soundHub.play('music', { volume: 0.6, loop: true });
soundHub.mute('music');
soundHub.unmute('music'); // back at 0.6
Good to know
- It does nothing for a sound that is not muted. Before 6.4.0 it set such a sound to
defaultVolume. - If
play()was given avolumewhile the sound was muted,unmutereturns to that volume. - On a stream from
loadStreamit does nothing unless the stream is muted. - Dispatches
SoundEventsEnum.UNMUTED('unmuted'). For an id that is not loaded, the error is logged, stored forgetLastErrorand dispatched as anerrorevent. - This does not lift a global mute. Use
unmuteAllSoundsfor that.
See also
mute: silence a sound.toggleMute: one call for a mute button.unmuteAllSounds: lift the global mute.