I've been able to work around most of the current bugs in SoundPool
while developing a step-sequencer app, but my sticking point is
stopping a non-looping sound once it's started.  I've seen this code
suggested here and in a few other threads as a workaround for the
pause/stop bug:

  mSoundPool.setLoop(soundId, 0);
  mSoundPool.setVolume(soundId, 0.0f, 0.0f);

Does this actually work for anyone to stop a playing NON-LOOPING sound
immediately?  In all of my testing on the emulator and G1 it only
works the first time I try to stop the playing sound, after that it
seems to have no effect and logcat shows no errors.  The only way I've
ever been able to stop a sound is to use the above code then re-
instantiate the SoundPool, which itself causes deadlock if done
repeatedly and is horribly inefficient in my case anyway.  I know all
of this is fixed in Cupcake, but am just interested to know other's
experiences in the current SoundPool implementation (especially since
it's not even clear if/when T-Mobile is going to bring Cupcake to G1
owners, and I'm just plain impatient :).

For anyone else struggling with SoundPool, in addition to the above
these are a few points I've found through a LOT of testing:

srcQuality - has no effect, use the default 0
priority - seems to have no effect, use the default 1
volume - valid values are floats 0.0 to 1.0
rate - valid values are floats 0.5 to 1.5
maxStreams - maximum concurrent streams (ie, playing a 200ms sound
twice 50ms apart uses 2 streams since they overlap)
setLoop()/setVolume() - if you're not looping the sound are
unnecessary as you can set volume in play()
pause/stop/resume - DON'T USE :)
should you use it at all? - if you don't need to change pitch,
personally I would suggest reading the source for SoundPool/
SoundPoolThread and creating your own implementation using
MediaPlayers as others have suggested.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to