有什么方法可以替换或静音android中的相机快门声音吗

有什么方法可以替换或静音android中的相机快门声音吗

本文介绍了有什么方法可以替换或静音android中的相机快门声音吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用代码中的其他内容替换快门声音(相机在拍摄照片时发出的声音).我希望它会像铃声或通知一样,但我在其他任何地方都看不到它.我已经看到了在拍照前将手机静音的代码,然后立即取消静音,但我更喜欢用另一个 mp3 或 ogg 替换声音.

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.

了解如果你有一个root的手机,你可以替换文件.这不是我的应用的解决方案.

Understand if you have a rooted phone, you can replace the file. 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);

谢谢!

推荐答案

如果你使用 Camera 对象,你可以提供一个 Camera.ShutterCallback 并播放任何你想要的东西想要.

If you are using the Camera object, you can supply a Camera.ShutterCallback and play whatever you want.

如果您使用 Intent 启动另一个应用程序来拍照,该应用程序可以选择在拍照时播放的内容.

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.

您的静音解决方案是对用户不利的,好像在这段时间内还有其他需要播放系统声音的东西,用户不会听到它.

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.

这篇关于有什么方法可以替换或静音android中的相机快门声音吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 08:48