diff --git a/component/video/camera.tsx b/component/video/camera.tsx index 9c5eae0..5f81b29 100644 --- a/component/video/camera.tsx +++ b/component/video/camera.tsx @@ -36,10 +36,10 @@ export default function CameraScreen(): React.ReactElement { } const device = useCameraDevice('back') - const format = useCameraFormat(device, [ - { videoResolution: { width: 3048, height: 2160 } }, - { fps: 60 } - ]) + // const format = useCameraFormat(device, [ + // { videoResolution: { width: 3048, height: 2160 } }, + // { fps: 60 } + // ]) if (device === null) { return Camera not available. Does user have permissions: {hasPermission} @@ -52,9 +52,10 @@ export default function CameraScreen(): React.ReactElement { ref={camera} style={StyleSheet.absoluteFill} device={device} - format={format} + // format={format} onInitialized={onInitialized} video={true} + photo={false} // orientation='portrait' // TODO: figure out what this looks like to the native module isActive={true} /> diff --git a/component/video/capture-button.tsx b/component/video/capture-button.tsx index c234c9e..745ee64 100644 --- a/component/video/capture-button.tsx +++ b/component/video/capture-button.tsx @@ -1,5 +1,7 @@ import React, { useCallback, useRef, useState } from 'react'; import { TouchableOpacity, StyleSheet, View } from 'react-native'; +import { CameraRoll } from "@react-native-camera-roll/camera-roll"; + export const RecordingButton = ({ style, camera, onMediaCaptured, enabled, setIsPressingButton }) => { @@ -8,12 +10,14 @@ export const RecordingButton = ({ style, camera, onMediaCaptured, enabled, setIs const [, setRecordingState] = useState(false); const onStoppedRecording = useCallback(() => { + console.log(' on stopped recording called') isRecording.current = false setRecordingState(false) console.log('stopped recording video!') }, []) const stopRecording = useCallback(async () => { + console.log(' stop recording called') try { if (camera.current === null) { throw new Error('Camera ref is null!') // Error handling could be more graceful @@ -37,15 +41,20 @@ const startRecording = useCallback(() => { console.error('Recording failed!', error) onStoppedRecording() }, - onRecordingFinished: (video) => { + onRecordingFinished: async (video) => { console.log(`Recording successfully finished! ${video.path}`) onMediaCaptured(video, 'video') + const path = video.path + await CameraRoll.saveAsset(`file://${path}`, { + type: 'video', + }) onStoppedRecording() }, }) // TODO: wait until startRecording returns to actually find out if the recording has successfully started console.log('called startRecording()!') isRecording.current = true + console.log('after setting isRecording ref') setRecordingState(true) } catch (e) { console.error('failed to start recording!', e, 'camera') @@ -60,6 +69,8 @@ const handlePress = () => { } }; +// console.log('ref', isRecording.current) + return (