diff --git a/Camera.js b/Camera.js index f83d8de..a3a59e1 100644 --- a/Camera.js +++ b/Camera.js @@ -88,6 +88,7 @@ export default class Camera extends Component { PropTypes.string, PropTypes.number ]), + playSoundOnCapture: PropTypes.bool, torchMode: PropTypes.oneOfType([ PropTypes.string, PropTypes.number @@ -108,6 +109,7 @@ export default class Camera extends Component { captureQuality: CameraManager.CaptureQuality.high, defaultOnFocusComponent: true, flashMode: CameraManager.FlashMode.off, + playSoundOnCapture: true, torchMode: CameraManager.TorchMode.off, mirrorImage: false, }; @@ -159,6 +161,7 @@ export default class Camera extends Component { options = { audio: props.captureAudio, mode: props.captureMode, + playSoundOnCapture: props.playSoundOnCapture, target: props.captureTarget, quality: props.captureQuality, type: props.type, diff --git a/README.md b/README.md index 5892c88..65dc6d2 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,12 @@ Values: The `orientation` property allows you to specify the current orientation of the phone to ensure the viewfinder is "the right way up." +#### `Android` `playSoundOnCapture` + +Values: `true` (default) or `false` + +This property allows you to specify whether a sound is played on capture + #### `iOS` `onBarCodeRead` Will call the specified method when a barcode is detected in the camera's view. diff --git a/android/src/main/java/com/lwansbrough/RCTCamera/RCTCameraModule.java b/android/src/main/java/com/lwansbrough/RCTCamera/RCTCameraModule.java index 7776ba9..5331955 100644 --- a/android/src/main/java/com/lwansbrough/RCTCamera/RCTCameraModule.java +++ b/android/src/main/java/com/lwansbrough/RCTCamera/RCTCameraModule.java @@ -7,6 +7,7 @@ package com.lwansbrough.RCTCamera; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.hardware.Camera; +import android.media.MediaActionSound; import android.net.Uri; import android.os.Environment; import android.provider.MediaStore; @@ -168,6 +169,12 @@ public class RCTCameraModule extends ReactContextBaseJavaModule { promise.reject("No camera found."); return; } + + if (options.getBoolean("playSoundOnCapture")) { + MediaActionSound sound = new MediaActionSound(); + sound.play(MediaActionSound.SHUTTER_CLICK); + } + RCTCamera.getInstance().setCaptureQuality(options.getInt("type"), options.getString("quality")); camera.takePicture(null, null, new Camera.PictureCallback() { @Override