简体   繁体   English

如何在Android手机上静音相机快门声音

[英]How to mute camera shutter sound on android phone

Is there any way to mute the camera shutter sound in Android (not rooted phone)? 是否有任何方法可以在Android(非root手机)中静音相机快门声音?

I use this code to mute my audio sound when taking picture: 拍照时我使用此代码静音我的音频声音:

  AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
    int streamType = AudioManager.STREAM_SYSTEM;
    mgr.setStreamSolo(streamType, true);
    mgr.setRingerMode(AudioManager.RINGER_MODE_SILENT);
    mgr.setStreamMute(streamType, true);

I mute the sound and silent the phone. 我把声音静音,手机静音。

mCamera.takePicture(null, null, photoCallback); 

then take the picture 然后拍照

It's working on HTC HERO, HTC Desire, Motorola ME860, MotoA953 . 它正在开发HTC HERO, HTC Desire, Motorola ME860, MotoA953 But when I tested it on Samsung Tab p1000 and Sony Experia R800i , it's not working. 但是当我在Samsung Tab p1000Sony Experia R800i上进行测试时,它无法正常工作。 Is there any other work around? 还有其他工作吗?

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.. 不要使用AudioManager.setStreamMute()方法,因为在2.3以下版本的android上有一个已知问题..

Since API level 17 (4.2) there is a proper, reliable way to do this, if the phone manufacturer supports it. 从API级别17(4.2)开始,如果手机制造商支持,则有一种正确,可靠的方法。

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. 您需要在调用Camera.getCameraInfo将id设置为相应的摄像机ID,或者在从0到Camera.getNumberOfCameras() - 1的循环Camera.getNumberOfCameras()它们全部禁用。

The developer documentation recommends that you play another sound in place of the shutter sound, but you're not obliged to. 开发人员文档建议您播放另一种声音来代替快门声音,但您没有义务。

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. 无论如何,那里有许多静音相机应用程序,Camera + ICS实际上是在默认的ICS相机上构建的,但是有一个Silent Shutter选项,所以它必须是可能的。

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. 在这种情况下,似乎无法禁用快门声音。

我能想到的一种疯狂方式是获得静音手机的许可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM