问题
Is there a way I can tell if a certain sound is playing in SoundPool??? I.E.
if(MySound./*Command Goes Here*/()==true{
//Do stuff
}
I would appreciate if you could point me in the right direction or give me the code. I am not able to find any thing that does this on the docs.
回答1:
This is not possible using SoundPool.
See Android SoundPool: get notified when end of played for two other ideas:
- Use
MediaPlayer, which provides anOnCompletionListener, instead ofSoundPool - Use
MediaPlayerin conjunction withSoundPool. Load the sound in aMediaPlayerbeforehand to get the duration and keep track of whether the sound is done playing based its duration when played withSoundPool.
来源:https://stackoverflow.com/questions/14086150/android-how-to-tell-if-a-sound-is-playing-in-soundpool