Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
480 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...