-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera2.js
71 lines (63 loc) · 1.57 KB
/
Camera2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React, { Component, PropTypes } from 'react';
import ReactNative, {
requireNativeComponent,
UIManager,
StyleSheet,
PermissionsAndroid,
Platform,
} from 'react-native';
const NCamera2 = requireNativeComponent('Camera2', Camera2, {});
const styles = StyleSheet.create({
camera: {
flex: 1,
}
});
export default class Camera2 extends Component {
stop(callback) {
UIManager.dispatchViewManagerCommand(
this.getNodeHandle(),
UIManager.Camera2.Commands.stop,
null
);
}
record(callback) {
UIManager.dispatchViewManagerCommand(
this.getNodeHandle(),
UIManager.Camera2.Commands.record,
null
);
}
image(callback) {
UIManager.dispatchViewManagerCommand(
this.getNodeHandle(),
UIManager.Camera2.Commands.image,
null
);
}
getNodeHandle() {
return ReactNative.findNodeHandle(this.refs.recorder);
}
render() {
return (
<NCamera2
{...this.props}
ref="recorder"
style={[styles.camera, this.props.style]}
/>
);
}
}
Camera2.propTypes = {
onRecordingStarted: PropTypes.func,
onRecordingFinished: PropTypes.func,
onCameraAccessException: PropTypes.func,
onCameraFailed: PropTypes.func,
onPermissionDenied: PropTypes.func,
onImageCaptureFinish: PropTypes.func,
type: PropTypes.oneOf(['front', 'back']),
flash: PropTypes.oneOf(['on', 'off','auto']),
torch: PropTypes.oneOf(['torch_on', 'torch_off']),
isVideo: PropTypes.oneOf(['yes', 'no']),
videoEncodingBitrate: PropTypes.number,
videoEncodingFrameRate: PropTypes.number
};