android-audio-bypass
android-audio-bypass copied to clipboard
Play On Awake doesn't always work
I think there's a race here: the play-on-awake feature calls Play() right after RegisterSoundFile(), but SoundPool loads the sound file asynchronously. So there's no guarantee that the sound is ready to play at the point where Play() is called.
The plugin needs to have a SoundPool OnLoadCompleteListener. It could provide a WaitUntilLoaded(soundId, timeout) method, allowing AndroidAudioBypass.Start() to register the sound file, wait until it's loaded, and play it. This has the disadvantage of stalling the game engine while sounds load.
A more sophisticated scheme would have a coroutine that watched for load completion and played the sound when ready.