Play sound continuously onTouch()

前端 未结 4 1564
傲寒
傲寒 2021-01-20 02:48

I want to play a gun shot sound continuously by onTouch. I am doing this for automatic gun sounds. So i have problem with there is delay in sound looping. which does not giv

4条回答
  •  孤街浪徒
    2021-01-20 03:07

    you can use SoundPool instead of MediaPlayer for better performance.

    • SoundPool play sound imidiatly.
    • you can play 3+ sounds in parallel.
    • We make use of the setRate across it's full range [0.5f-2.0f].

    for sounds like gunshoot, or knocking door sound etc, use SoundPool cause it has a lot advantages as compare to MediaPlayer. http://developer.android.com/reference/android/media/SoundPool.html http://examples.javacodegeeks.com/android/android-soundpool-example/

提交回复
热议问题