(Android) How to tell if a sound is playing in soundpool

旧时模样 提交于 2019-12-12 13:09:29

问题


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 an OnCompletionListener, instead of SoundPool
  • Use MediaPlayer in conjunction with SoundPool. Load the sound in a MediaPlayer beforehand to get the duration and keep track of whether the sound is done playing based its duration when played with SoundPool.


来源:https://stackoverflow.com/questions/14086150/android-how-to-tell-if-a-sound-is-playing-in-soundpool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!