mirror of
https://github.com/status-im/react-native-camera.git
synced 2025-02-24 09:48:17 +00:00
Merge pull request #1441 from react-native-community/feat/play-sound
feat(play-sound): play sound on capture (android)
This commit is contained in:
commit
a506fda0a3
@ -120,6 +120,11 @@ public class CameraViewManager extends ViewGroupManager<RNCameraView> {
|
||||
view.setUsingCamera2Api(useCamera2Api);
|
||||
}
|
||||
|
||||
@ReactProp(name = "playSoundOnCapture")
|
||||
public void setPlaySoundOnCapture(RNCameraView view, boolean playSoundOnCapture) {
|
||||
view.setPlaySoundOnCapture(playSoundOnCapture);
|
||||
}
|
||||
|
||||
@ReactProp(name = "faceDetectorEnabled")
|
||||
public void setFaceDetecting(RNCameraView view, boolean faceDetectorEnabled) {
|
||||
view.setShouldDetectFaces(faceDetectorEnabled);
|
||||
|
@ -4,6 +4,7 @@ import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.media.CamcorderProfile;
|
||||
import android.media.MediaActionSound;
|
||||
import android.os.Build;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.SparseArray;
|
||||
@ -54,6 +55,7 @@ public class RNCameraView extends CameraView implements LifecycleEventListener,
|
||||
private Map<Promise, File> mPictureTakenDirectories = new ConcurrentHashMap<>();
|
||||
private Promise mVideoRecordedPromise;
|
||||
private List<String> mBarCodeTypes = null;
|
||||
private Boolean mPlaySoundOnCapture = false;
|
||||
|
||||
private boolean mIsPaused = false;
|
||||
private boolean mIsNew = true;
|
||||
@ -201,10 +203,18 @@ public class RNCameraView extends CameraView implements LifecycleEventListener,
|
||||
initBarcodeReader();
|
||||
}
|
||||
|
||||
public void setPlaySoundOnCapture(Boolean playSoundOnCapture) {
|
||||
mPlaySoundOnCapture = playSoundOnCapture;
|
||||
}
|
||||
|
||||
public void takePicture(ReadableMap options, final Promise promise, File cacheDirectory) {
|
||||
mPictureTakenPromises.add(promise);
|
||||
mPictureTakenOptions.put(promise, options);
|
||||
mPictureTakenDirectories.put(promise, cacheDirectory);
|
||||
if (mPlaySoundOnCapture) {
|
||||
MediaActionSound sound = new MediaActionSound();
|
||||
sound.play(MediaActionSound.SHUTTER_CLICK);
|
||||
}
|
||||
super.takePicture();
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,7 @@ type PropsType = ViewPropTypes & {
|
||||
onTextRecognized?: ({ textBlocks: Array<TrackedTextFeature> }) => void,
|
||||
captureAudio?: boolean,
|
||||
useCamera2Api?: boolean,
|
||||
playSoundOnCapture?: boolean,
|
||||
};
|
||||
|
||||
const CameraManager: Object = NativeModules.RNCameraManager ||
|
||||
@ -154,6 +155,7 @@ export default class Camera extends React.Component<PropsType> {
|
||||
pendingAuthorizationView: PropTypes.element,
|
||||
captureAudio: PropTypes.bool,
|
||||
useCamera2Api: PropTypes.bool,
|
||||
playSoundOnCapture: PropTypes.bool,
|
||||
};
|
||||
|
||||
static defaultProps: Object = {
|
||||
@ -201,6 +203,7 @@ export default class Camera extends React.Component<PropsType> {
|
||||
),
|
||||
captureAudio: false,
|
||||
useCamera2Api: false,
|
||||
playSoundOnCapture: false,
|
||||
};
|
||||
|
||||
_cameraRef: ?Object;
|
||||
|
Loading…
x
Reference in New Issue
Block a user