sound
sound copied to clipboard
Check if sound is played
I searched the documentation, but I can't seem to find any method/ state to check if a sound or any sound at all is currently playing. What I would like to do in my case would be to check whether a sound is played and if not, then to play it. And in another case check if any sound is played and then play a specific sound depending on the result.
Each instance of Sound
has an isPlaying
property: https://pixijs.io/pixi-sound/docs/PIXI.sound.Sound.html#isPlaying
Thank you for the quick response. I am looking for something a bit more general maybe on the Pixi.sound
level, so that I don't have to check each and every sound asset in my "library" if it is currently playing.
You could do something like this.
function isPlayingAny() {
for (const alias in PIXI.sound._sounds) {
if (PIXI.sound._sounds[alias].isPlaying()) {
return true;
}
}
return false;
}
Seems like a useful feature to add.
Thanks for the advice! :)