I am using the takePicture()
method from the Camera
class. It takes the picture , but it makes no sound! My client wants the default click sound that Android makes.
I have seen other threads and it seems that the problem is in disabling the sound, not the opposite! Why is it that my app is not making the click sound??
I also had this problem. I solved it by using following code: The following is used to call takePicture:
clickButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
mCamera.takePicture(shutterCallback, null, onPicTaken);
}
});
Now shutteerCallBack:
private final ShutterCallback shutterCallback = new ShutterCallback() {
public void onShutter() {
AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mgr.playSoundEffect(AudioManager.FLAG_PLAY_SOUND);
}
};
Now Do whatever after taking picture from camera:
/**
* This will be called after taking picture from camera.
*/
final transient private PictureCallback onPicTaken = new PictureCallback() {
/**
* After taking picture, onPictureTaken() will be called where image
* will be saved.
*
*/
@Override
public void onPictureTaken(final byte[] data, final Camera camera) {
}
This will play sound on clicking capture button.
Thank you :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With