开发者

Is there any predefined sound on android?

开发者 https://www.devze.com 2023-03-16 05:28 出处:网络
I\'m wondering, if there is any predefined sounds in Android th开发者_高级运维at I can use in my application.

I'm wondering, if there is any predefined sounds in Android th开发者_高级运维at I can use in my application.

I was trying to use a class called SoundManager which is build specifically for sound playing in an efficient way.

I realized that what I need is much much smaller than this class. I need a click sound when the button is clicked and a navigation sound when the user navigate through a menu or a set of buttons.

I guess there is something in the android API fit to my purpose but I could not find it. any help please in finding it and hoe to use it?


You could look into the View.playSoundEffect api. This method accepts a SoundEffectConstants value where, among others, a CLICK constant is available.


Using the MediaPlayer it's really simple, see for instance this SO thread: Android - play sound on button click - Null pointer exception

0

精彩评论

暂无评论...
验证码 换一张
取 消