diff options
author | Ivan Chen <ivan@tagg.id> | 2021-07-02 15:59:07 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-07-02 15:59:07 -0400 |
commit | 80f52fa900817d614680a60f0c35592cf48310b0 (patch) | |
tree | 4701e4f9b27b3f62a619b2e8a8daa4bc6da04aed /src/utils/camera.ts | |
parent | cef9d8e9908936a10a9aa0069e364ebf5970da4c (diff) |
Add long press to take video
Diffstat (limited to 'src/utils/camera.ts')
-rw-r--r-- | src/utils/camera.ts | 17 |
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!')) |