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