user1161410
user1161410

Reputation: 49

How to add sound on a button on click event?

I have a page having 3 buttons i need to add different beep like sound to the buttons instead of the default click sound of buttons so i have three beep sounds and three buttons i.e one beep sound for one button the button1,button2,button3 are three buttons and beep_sound1,beep_sound2,beep_sound3 are sounds for those buttons, i want that when someone clicks on button1 they should be able to hear beep_sound1 and when someone clicks on button2 beep_sound2 and for button3 beep_sound3, i tried using the MediaPlayer Class for coding for sound effect On click event of button but when i tested this on emulator the sound was coming perfectly but when i run it on phone it doesn't loads properly and says memory full and when i install apk file on phone and test the app i hear two sounds when i click on button1 i hear two sounds one is beep_sound1 and along with that sound the default sound of android is also their but i only need my sound to be played when i click on the button, how do i figure this out i don't understand why their are two sounds one is the default sound of android and another is my beep_sound i don't want the default sound i only want my sound to be heard when someone clicks the buttons.

Upvotes: 3

Views: 1592

Answers (1)

Orlymee
Orlymee

Reputation: 2357

set the soundEffectsEnabled property to false on your button.

Upvotes: 4

Related Questions