stop
stop(id: string, skipDispatchEvent?: boolean): void;
Stop a sound by its ID. Unlike pause, stop discards the playback position — calling play again will restart from the beginning.
| Parameter | Type | Description |
|---|---|---|
id | string | ID of the sound to stop |
skipDispatchEvent | boolean | When true, suppresses the stop event |
Example
await soundManager.loadSounds([{ id: 'tokyo-train', url: 'tokyo-train-melody.mp3' }]);
soundManager.play('tokyo-train', { loop: true });
// Stop and discard position
soundManager.stop('tokyo-train');
// Playing again restarts from 0
soundManager.play('tokyo-train');
stopped
Tip: After stopping, clicking Play restarts from the beginning. Use pause if you want to resume from the same position.