The correct way to play short sounds Android?

后端 未结 3 2029
离开以前
离开以前 2020-12-02 22:33

I am creating an application that will have multiple images on the screen, these images will be buttons and when tapped will play a short sound. I researched this and could

3条回答
  •  温柔的废话
    2020-12-02 22:55

    You can use SoundPool. It fits what you want to do perfectly.

    You'll just need a way to store the sound effect IDs corresponding to each image (or button).

    Perhaps extend Button to store associated sound effect ID. And use a common SoundPool to play the sound effect associated to the id when the button is touched.

    You can read more about SoundPool here.

提交回复
热议问题