Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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!

like image 414
MWMWM Avatar asked Mar 13 '11 12:03

MWMWM


1 Answers

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.

like image 176
CommonsWare Avatar answered Oct 05 '22 12:10

CommonsWare