toggleMute
toggleMute(id: string): void;
Toggle the mute state of a specific sound by its ID. If the sound is muted, it becomes unmuted and vice versa. This is a convenience method that avoids needing to check the current state before calling mute or unmute.
Example
await soundManager.loadSounds([{ id: 'bells-melody', url: 'bells-melody.mp3' }]);
soundManager.play('bells-melody', { loop: true });
// Toggle mute on/off — ideal for a single mute button
soundManager.toggleMute('bells-melody');
soundManager.toggleMute('bells-melody');
🔇 Press Play to start
Try it: Click the Mute/Unmute button to toggle the bells melody sound's mute state.
toggleMute is a single method that switches between muted and unmuted — great for a UI toggle button.