diff options
author | Ivan Chen <ivan@tagg.id> | 2021-07-30 11:31:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-30 11:31:32 -0400 |
commit | 452f3fb44838c367f40e8aa57db2e274a357afd2 (patch) | |
tree | 4a3487413b8773f120271380e5c2902dadf690d8 /src/utils | |
parent | eabc3c82f0ac2ffa2dfb26ee7bc792fd6a48491a (diff) | |
parent | e50a0321d73df5169b79dded7a57cfa3a9b62adc (diff) |
Merge pull request #539 from IvanIFChen/tma1035-bugfix-camera-timer-animation
[TMA-1035] [BUGFIX] Record Video Animation Issues
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/camera.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/utils/camera.ts b/src/utils/camera.ts index f21ef133..ec2615de 100644 --- a/src/utils/camera.ts +++ b/src/utils/camera.ts @@ -10,7 +10,11 @@ import { } from 'react-native-camera'; import {ProcessingManager} from 'react-native-video-processing'; import ImagePicker, {ImageOrVideo} from 'react-native-image-crop-picker'; -import {ERROR_UPLOAD} from '../constants/strings'; +import { + ERROR_UPLOAD, + ERROR_UPLOAD_EXCEED_MAX_VIDEO_DURATION, +} from '../constants/strings'; +import {MAX_VIDEO_RECORDING_DURATION} from '../constants'; /* * Captures a photo and pauses to show the preview of the picture taken @@ -39,7 +43,7 @@ export const takeVideo = ( if (cameraRef !== null) { const options: RecordOptions = { orientation: 'portrait', - maxDuration: 60, + maxDuration: MAX_VIDEO_RECORDING_DURATION, quality: '1080p', }; cameraRef.current?.recordAsync(options).then((vid) => { @@ -73,6 +77,14 @@ export const navigateToMediaPicker = ( compressVideoPreset: 'Passthrough', }) .then((media) => { + if ( + 'duration' in media && + media.duration !== null && + media.duration > MAX_VIDEO_RECORDING_DURATION * 1000 + ) { + Alert.alert(ERROR_UPLOAD_EXCEED_MAX_VIDEO_DURATION); + return; + } callback(media); }) .catch((err) => { |