Sound component's current instance

Hello,

Is there any way to get which instance of sound is playing currently.

I have 3 slots in sound component and while user pauses or stop the audio I am checking playing status for all 3 instances. It would be great to get which audio slot is playing at any moment.

Thanks,
Good day

Hi @MTHC_Pulkit,

No, I don’t think there is one, looking at the docs right now. Potentially you could scan the sound component object and find a private property, but that isn’t recommended.

Here is a one liner to get the active slot (don’t use it in script update/per frame though, it creates garbage):

const activeSlot = Object.values(this.entity.sound.slots).find(o => o.isPlaying);

Thank you @Leonidas for your solution.