Playing sound effect for button click

All your problems with Audio, Video and Images.

Playing sound effect for button click

Postby maduranga » Mon Oct 11, 2010 3:31 pm

Hello,

I'm trying to use the
Code: Select all
playSoundEffect ()
method to play a sound effect when a button is clicked, but so far its' proved very difficult for some reason.

I have defined the following.
Code: Select all
    <ImageButton android:id="@+id/Button_flip" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:text="FLIP!"
    android:src="@drawable/flip" android:soundEffectsEnabled="true">
    </ImageButton>


Then,

Code: Select all
button_flip.playSoundEffect(android.view.SoundEffectConstants.CLICK);

is called in
Code: Select all
onCreate()
method. But I cannot seem to get it to sound when I click the button. What am I missing here? The documentation has nothing much to go on.

Do I need to define/call in the onClick() method or register to which event the sound should be played?

Any help is appreciated.

Thank you.
maduranga
Freshman
Freshman
 
Posts: 8
Joined: Wed Sep 22, 2010 5:25 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 8 guests