getSoundState
getSoundState(id: string): SoundStateInfo;
Get the current state information of a sound by its ID. Returns detailed state data about the sound's playback status.
Example
await soundManager.loadSounds([{ id: 'helicopter', url: 'helicopter.mp3' }]);
soundManager.play('helicopter', { loop: true });
const state = soundManager.getSoundState('helicopter');
console.log(state);
// { state: 'playing', position: 2.5, duration: 30, ... }
Sound State
stopped
isPlaying: falseisPaused: falseisStopped: trueTry it: Use the buttons to change the helicopter sound's state. Watch the status update in real time —
isPlaying, isPaused, and isStopped are mutually exclusive.