When you call
audioNode.playInstance() there is no way to stop or adjust any paramaters of the sound, and after looking at the javadoc this seems to be the intended functionality.
Is there any easy way to access a list of the instances of the audio that get played when you call
playInstance()? I briefly looked at the source code but don’t see a straightforward way to get a specific audio instance from the renderer, and don’t have much experience with this area of the source code.
If it is not possible to get an audio instance, then it seems like there would never be a viable reason to use
playInstance() in place of
play() if you ever want to have a game with pausing or a sound options menu where you can turn down the volume of sounds that are currently playing and have the results immediately take effect when you resume. This seems important when I think back to the days of being a kid playing games at night, when a loud explosion would happen and I’d quickly pause to turn down the effects volume slider in the menu so I wouldn’t wake everyone up. It would be annoying to un-pause only to hear the explosion still going at full volume lol.
I looked at the Hello Audio tutorial and I see it uses
.play() for ambient sounds and uses
.playInstance() for a gun shot sound. So I’m guessing the idea was that the gun shot should be short enough and that would make it okay to have an un-editable sound instance, but this is still potentially problematic because even a sound effect like a gunshot that lasts half a second could still be interrupted by the pause screen multiple times before the sound finishes.