How to mute camera shutter sound on android phone

前端 未结 5 1313
春和景丽
春和景丽 2020-12-14 02:33

Is there any way to mute the camera shutter sound in Android (not rooted phone)?

I use this code to mute my audio sound when taking picture:

  AudioM         


        
相关标签:
5条回答
  • 2020-12-14 02:54

    Since API level 17 (4.2) there is a proper, reliable way to do this, if the phone manufacturer supports it.

    First, detect whether you can disable the shutter sound programatically, then disable it

    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(id, info);
    if (info.canDisableShutterSound) {
        mCamera.enableShutterSound(false)
    }
    

    You'll need to set id to the appropriate camera id in the call to Camera.getCameraInfo, or disable them all in a loop from 0 to Camera.getNumberOfCameras()- 1.

    The developer documentation recommends that you play another sound in place of the shutter sound, but you're not obliged to.

    0 讨论(0)
  • 2020-12-14 02:55

    One crazy way i can think is to get the permission to mute the phone.

    0 讨论(0)
  • 2020-12-14 02:56

    The method you've posted already is actually the best one I can find/think of. The reason it doesn't work is because it's not supposed to. In fact, in many places (most of Europe, Japan, parts of US, etc.) it's illegal to disable the shutter sound. This is so that you can't take pictures in places you're not supposed to, and so you don't take pictures of people without their permission, and so on. It's just a shot in the dark that the manufacturer has purposely tried to make sure you can't do it no matter what (though technically there's always a way), but when you think about it, logically there's no reason your code shouldn't work right? It's simple, basic, makes sense. Anyways, there are many silent camera apps out there and Camera+ ICS is actually built on the default ICS camera but has a Silent Shutter option so it must be possible.

    0 讨论(0)
  • 2020-12-14 03:06

    try this code:

    AudioManager manager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    if(TextUtils.equals(muteMode, "mute")){
        manager.setStreamVolume(AudioManager.STREAM_SYSTEM, 0 , AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
    }else{
        manager.setStreamVolume(AudioManager.STREAM_SYSTEM, manager.getStreamMaxVolume(AudioManager.STREAM_SYSTEM) , AudioManager.FLAG_ALLOW_RINGER_MODES);
    }
    //here continue to take picture...
    

    do not use AudioManager.setStreamMute() method since there is a known issue on android below version 2.3..

    0 讨论(0)
  • 2020-12-14 03:06

    there are a phones out there which play the shutter sound on their own. In this case, it seems to not be possible to disable the shutter sound.

    0 讨论(0)
提交回复
热议问题