Skip to main content

setGlobalVolume

setGlobalVolume(volume: number): void;

Set the global volume for all sounds. This serves as a master volume control — all sounds are multiplied by this value. Use getGlobalVolume to retrieve the current value.

ParameterTypeDescription
volumenumberVolume level between 0 (silent) and 1 (full)

Example

await soundManager.loadSounds([{ id: 'techno-tune', url: 'techno-tune.mp3' }]);

soundManager.play('techno-tune', { loop: true });

// Set global volume to 50%
soundManager.setGlobalVolume(0.5);

// Mute everything
soundManager.setGlobalVolume(0);

// Restore full volume
soundManager.setGlobalVolume(1);
🔉 Global Volume60%
0%100%
Try it: Play the techno-tune sound and adjust the global volume slider. This affects all sounds — useful for a master volume control.