suspendContext
suspendContext(): Promise<void>;
Suspend the audio context, pausing all audio processing. This is useful when the user switches to another tab or app — it frees up system audio resources. Use resumeContext to restart audio processing.
Example
await soundManager.loadSounds([{ id: 'piano', url: 'piano.mp3' }]);
soundManager.play('piano', { loop: true });
// Suspend when the user navigates away
await soundManager.suspendContext();
// Later: resume to continue playback
await soundManager.resumeContext();
AudioContext State
unknown
Try it: Play the piano, then suspend the AudioContext — audio processing stops completely. Resume to continue. Use
suspendContext() when the user switches away, resumeContext() when they return.