On Android 2.2+ there is something called SoundPool.OnLoadCompleteListener allowing to know whether a sound has been loaded successfully or not.
I am targeting lower API version (ideally 1.6 but could go for 2.1) and I need to know whether a sound has been loaded correctly (as it is selected by the user). What’s the proper way to do it?
I hope not load the sound once with MediaPlayer and if correct with SoundPool?!
I implemented a kind-of-compatible
OnLoadCompleteListenerclass that works at least for Android 2.1.The constructor takes a
SoundPoolobject, and sounds for which theSoundPool.load(..)has been called must be registered withOnLoadCompleteListener.addSound(soundId). After this, the listener periodically attempts to play the requested sounds (at zero volume). If successful, it calls your implementation ofonLoadComplete, like in the Android 2.2+ version.Here’s a usage example:
And here’s the source: