开发者

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.

Understand if you have a rooted phone, you can replace the file. This is not a so开发者_如何学Clution 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.

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.


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. you could compress the image to jpeg or png. In this way, there no shutterCallback to be implemented. and therefore you can play any sound you whant or none when taking a picture.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜