I have a custom camera implementation which I would like to have have my own sound when the picture is taken using API 10. I have the following code which does play my sound but it also plays the default camera sound as well, I need to only play my camera sound and not the default one. 
   //takes picture
   mCamera.takePicture(myShutterCallback, myPictureCallback_RAW, myPictureCallback_JPG);
   ShutterCallback myShutterCallback = new ShutterCallback() {
    @Override
    public void onShutter() {
        MediaPlayer.create(SecondCamera.this,R.raw.camera_click).start();
    }
};
                Try this,
if (android.os.Build.VERSION.SDK_INT>=android.os.Build.VERSION_CODES.JELLY_BEAN_MR1){
      camera.enableShutterSound(false);
}
else{
        AudioManager audio= (AudioManager)this.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
        currentVolume=audio.getStreamVolume(AudioManager.STREAM_SYSTEM);            
        audio.setStreamVolume(AudioManager.STREAM_SYSTEM, 0,   AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
        MediaPlayer media= MediaPlayer.create(SecondCamera.this,R.raw.camera_click);
        media.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
        isVolumeChanged=true;           
     }
Do the above before onShutter() then call media.start() on onShutter()
then on onPictureTaken() Do the following.
public void onPictureTaken(byte[] data, Camera camera) {
        if (isVolumeChanged){
            audio.setStreamVolume(AudioManager.STREAM_SYSTEM,currentVolume,AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
        }
    }      
Hope this helps!!!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With