Android: Camera #takePicture() No Shutter Sound When Taking Photos

Asked 2 years ago, Updated 2 years ago, 58 views

We are developing a camera app for Android.

android.hardware.Camera#takePicture(Camera.ShutterCallback shutter, Camera.PictureCallback raw, Camera.PictureCallback jpeg) was called to retrieve the captured data in callback, but somehow the shutter sound did not ring.

Are there any Camera parameters required to play the default shutter sound?

Supplement:

  • Just in case, we also verified that Camera#enableShutterSound(true); was called and true was returned before takePicture.(As long as you read enableShutterSound(boolean enabled) API Doc, this should have been set to play the default shutter sound correctly.)

  • If you take a picture with the standard (?) camera app Instagram, the same sound is played for each model (so I guess that's the default shutter sound for each device).

  • PictureCallback can be used to play sound on your own, but I don't feel like it because I want to avoid duplication.

Just to be sure, before takePicture, we also verified that Camera#enableShutterSound(true); was called and true was returned.(As long as you read enableShutterSound(boolean enabled) API Doc, this should have been set to play the default shutter sound correctly.)

When I take pictures with the standard (?) camera app Instagram, the same sound is played for each model (so I guess that's the default shutter sound for each device).

environment:

  • Nexus7 2014 (4.4.4)...does not play
  • xperia Acro HD (4.0.4)...does not play
  • compileSdkVersion21,buildToolsVersion'21.1.1'

android

2022-09-30 19:32

1 Answers

What I wrote on http://qiita.com/tao_s/items/13d809c12875a6a4b752 worked.

final Camera.ShutterCallback dummyCallback=new Camera.ShutterCallback(){
    @Override public void onShutter(){}
};
camera.takePicture(dummyCallback, null, this);

This makes a sound, but it doesn't sound when dummyCallback is null.


2022-09-30 19:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.