Skip to main content

isPlaying

isPlaying(id: string): boolean;

Check if a sound is currently playing. Returns true if the sound is actively playing, false otherwise.


Example

await soundHub.loadSounds([{ id: 'helicopter', url: 'helicopter.mp3' }]);

soundHub.play('helicopter', { loop: true });

// Check if the sound is currently playing
const playing = soundHub.isPlaying('helicopter');
console.log(playing); // true

soundHub.pause('helicopter');
console.log(soundHub.isPlaying('helicopter')); // false
Sound State
stopped
isPlaying: falseisPaused: falseisStopped: true
Try 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.