aboutsummaryrefslogtreecommitdiff
path: root/src/utils/camera.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/camera.ts')
-rw-r--r--src/utils/camera.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/utils/camera.ts b/src/utils/camera.ts
index 3937129a..7fa18b7c 100644
--- a/src/utils/camera.ts
+++ b/src/utils/camera.ts
@@ -2,6 +2,8 @@ import CameraRoll from '@react-native-community/cameraroll';
import {RefObject} from 'react';
import {Alert} from 'react-native';
import {
+ RecordOptions,
+ RecordResponse,
RNCamera,
TakePictureOptions,
TakePictureResponse,
@@ -29,6 +31,21 @@ export const takePicture = (
}
};
+export const takeVideo = (
+ cameraRef: RefObject<RNCamera>,
+ callback: (vid: RecordResponse) => void,
+) => {
+ if (cameraRef !== null) {
+ const options: RecordOptions = {
+ orientation: 'portrait',
+ maxDuration: 10,
+ };
+ cameraRef.current?.recordAsync(options).then((vid) => {
+ callback(vid);
+ });
+ }
+};
+
export const saveImageToGallery = (capturedImageURI: string) => {
CameraRoll.save(capturedImageURI, {album: 'Recents', type: 'photo'})
.then((_res) => Alert.alert('Saved to device!'))