I advise against using SoundPool. It is not part of the official SDK and will likely change in the future. There are also some bugs that can cause your thread to deadlock.
On Oct 28, 8:42 pm, Robert Green <[EMAIL PROTECTED]> wrote: > I used SoundPool. It's super buggy but if you're careful it does > work. I hope they clean it up in a future release. Do a search for > SoundPool and you'll find the message with my results in it. > > On Oct 28, 4:01 pm, tobias429 <[EMAIL PROTECTED]> wrote: > > > I am looking for a solution to play sounds multiple times in an > > application. In the application, as soon as a user performs operation > > A, the application shall respond with a *bing* sound. Performing > > operation B shall produce a *bong*. That means during the application > > life cycle, both sounds will potentially be played several dozen > > times. I have tried three different ways to achieve this. None of them > > seems to work: > > > For all options, I have added 2 wav files, one for *bing* and one for > > *bong* in the application's Resource Package. > > > Option 1: > > ======= > > For both wav files, I am opening a MediaPlayer via e.g. > > bingSound=MediaPlayer.create(context, resid). In the application, > > whenever a sound shall be played, I call bingSound.start(). > > > Result: > > This works fine the first time. If I call bingSound.start() a second > > time no sound plays, and I get an exception that I called start() on a > > MediaPlayer instance in the wrong state. > > > Option 2: > > ======= > > Whenever the application shall play a sound, I create a new > > MediaPlayer from scratch via e.g. > > bingSound=MediaPlayer.create(context, resid); bingSound.start() > > > Result: > > This works fine a number of times, until appearantly the maximum > > number of MediaPlayers is reached, and the application simply halts. > > > Option 3: > > ======= > > I create a new MediaPlayer via MediaPlayer.create(context, resid). I > > set looping to true. When the application shall play the sound, I call > > bingSound.start(). When the sound shall stop, I call > > bingSound.seekTo(0), followed by bingSound.pause(). > > > Result: > > This works fine for looping sounds. For the classical *bing* sound > > that shall only be played once and does not loop, it is next to > > impossible to time the calls in a way that the sound is only played > > once. > > > Question > > ======= > > Is there any possible approach to play the same, non looping sound > > several dozen times in an application? > > > Thanks for any help! > > > Tobias --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

