I have been attempting to play a bunch of sounds in my app as some views switch. The sound is narrative for the views and is between 3 and 10 seconds each, of which there are about 30.
First, I tried loading them all into a sound pool and passing it to a hashmap on program load, then I simply play them when required. This worked for the first 5 or 6 sounds but once I started to add more sounds to the sound pool, the later ones did not play. I assume this is due to the 1MB limit I have read about on soundpool.
I tried switching to just loading the sound and passing it straight to play on the next line however, no sounds play. Logcat just shows a reset and command cancelled for the player.
I switched then to loading the file and pointing to it with the hash map, however, even after doing an unload and loadimg a new sound at the same index it would just play the same sound every time.
I have tried MediaPlayer but it is ineffective for my desired application.
Can anyone suggest a way I should 开发者_StackOverflow社区look to implement this properly? And should I be trying to load all sounds before hand or not?
I think you need to wait for the load to complete before you can play it. Add an onLoadCompleteListener and then play it when that is invoked.
精彩评论