fadeGlobalIn
fadeGlobalIn(duration?: number, startVolume?: number, endVolume?: number): void;
Fade in the global volume over a specified duration. Optionally, set start and end volumes.
| Parameter | Type | Default | Description |
|---|---|---|---|
duration | number | 1 | Fade duration in seconds |
startVolume | number | 0 | Volume to start from |
endVolume | number | 1 | Volume to reach |
tip
Use fadeGlobalOut to fade out the global volume.
Example
await soundManager.loadSounds([{ id: 'techno-tune', url: 'techno-tune.mp3' }]);
// Play at zero volume
soundManager.play('techno-tune', { loop: true });
// Option 1: set volume to 0 then fade in
soundManager.setGlobalVolume(0);
soundManager.fadeGlobalIn(3, 0, 1);
// Option 2: fade in from current volume
soundManager.fadeGlobalIn(2, 0.3, 0.8);
Fade type:
⏱ Duration3s
0.5s8s
Try it: Play the techno-tune sound, then use Fade In to gradually raise the global volume or Fade Out to lower it across all sounds.