Skip to main content

unmute

Bring a muted sound back to the volume it had before mute.

unmute(id: string): void;

Parameters​

ParameterTypeDefaultDescription
idstringrequiredID 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 a volume while the sound was muted, unmute returns to that volume.
  • On a stream from loadStream it does nothing unless the stream is muted.
  • Dispatches SoundEventsEnum.UNMUTED ('unmuted'). For an id that is not loaded, the error is logged, stored for getLastError and dispatched as an error event.
  • This does not lift a global mute. Use unmuteAllSounds for that.

See also​