Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android mute camera shutter sound?

I am using this

camera.takePicture(null, rawCallback, jpegCallback);

but with some devices it makes a sound when the camera captures the image.

Please can any one help, how can I mute camera shutter sound?

like image 310
PankajAndroid Avatar asked Jan 23 '13 09:01

PankajAndroid


2 Answers

You can turn it off programmatically from 4.2 onwards with:

Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(id, info);
if (info.canDisableShutterSound) {
    mCamera.enableShutterSound(false);
}
like image 178
Jono Avatar answered Sep 27 '22 19:09

Jono


To mute, put this code before capturing an image

 AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
 mgr.setStreamMute(AudioManager.STREAM_SYSTEM, true);
 camera.takePicture(null, rawCallback, jpegCallback);

After 1 second it will unmute by putting in the below code:

 final Handler handler = new Handler();
 Timer t = new Timer();
 t.schedule(new TimerTask() {
    public void run() {
        handler.post(new Runnable() {
            public void run() {
            AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
            mgr.setStreamMute(AudioManager.STREAM_SYSTEM, false);
                    }
                });
            }
    }, 1000); 
like image 24
CoronaPintu Avatar answered Sep 27 '22 18:09

CoronaPintu