简体   繁体   English

在Android中有没有办法取代或静音相机快门声?

[英]Is there any way to replace or silence the camera shutter sound in android?

I'd like to replace the shutter sound (the sound the camera makes when snapping a photo) with something else in code. 我想用代码中的其他东西替换快门声(相机拍照时拍摄的声音)。 I was hoping it would be like ringtones or notifications, but I don't see anything anywhere other about it. 我希望它会像铃声或通知,但我没有看到任何其他任何关于它。 I've seen code to silence the phone right before taking the pic, and unsilencing it right after, but I'd prefer to replace the sound with another mp3 or ogg. 我已经看过代码在拍摄照片之前使手机静音,并且在之后取消静音,但我更愿意用另一个mp3或ogg替换声音。

Understand if you have a rooted phone, you can replace the file. 了解您是否拥有root电话,可以替换该文件。 This is not a solution for my app. 这不是我的应用程序的解决方案。

Just in my app. 就在我的应用程序中。 Idea would be to set it, then unset it. 想法是设置它,然后取消它。 Funny how after you type something out, re-read it, it helps think of it from a different perspective. 有趣的是,在你输入一些东西后,重新阅读它,它有助于从不同的角度思考它。 I've used the code below to shut down the audio service, and I play my sound right before. 我已经使用下面的代码来关闭音频服务,我之前播放我的声音。 Works as a great workaround. 作为一个伟大的解决方案。 Perhaps someday, we'll be able to set it. 也许有一天,我们将能够设置它。

   AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
   mgr.setStreamMute(AudioManager.STREAM_SYSTEM, true); 

Thanks! 谢谢!

If you are using the Camera object, you can supply a Camera.ShutterCallback and play whatever you want. 如果您使用的是Camera对象,则可以提供Camera.ShutterCallback并播放您想要的任何内容。

If you are using an Intent to launch another app to take the picture, that app gets to choose what it plays when the picture is taken. 如果您使用Intent启动另一个应用程序来拍照,该应用程序可以选择拍摄照片时播放的内容。

Your mute-the-audio solution is user-hostile, as if there is anything else that needs to play a system sound during that period of time, the user won't hear it. 您的静音音频解决方案是用户敌对的,就好像在那段时间内还有其他任何需要播放系统声音的内容,用户将听不到它。

You may use the data from the preview callback using a function to save it at a picture on some type of trigger such as a button, using onclick listener. 您可以使用函数将预览回调中的数据用于使用onclick侦听器将其保存在某些类型的触发器(如按钮)上的图片上。 you could compress the image to jpeg or png. 你可以将图像压缩为jpeg或png。 In this way, there no shutterCallback to be implemented. 这样,就不会实现shutterCallback。 and therefore you can play any sound you whant or none when taking a picture. 因此,你可以在拍照时播放任何你想要的声音。

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

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