Properly support orientation in recorded video

Fixes #72
This commit is contained in:
Ivan Malison 2024-02-08 11:17:35 -07:00
parent 2fd1f26325
commit c8999f8250
3 changed files with 7 additions and 2 deletions

@ -1 +1 @@
Subproject commit 1312c5be53fdf1912922a1412642e48200cff0aa
Subproject commit 19bf300bbefbe9c8244be3b1c8fbb7a9453ff8e2

View File

@ -223,6 +223,7 @@ export default function CameraScreen({
camera={camera}
onMediaCaptured={onMediaCaptured}
enabled={isCameraInitialized}
orientation={orientation}
/>
<View
style={[

View File

@ -17,6 +17,7 @@ interface RecordingButtonProps {
// eslint-disable-next-line no-unused-vars
onMediaCaptured: (media: VideoFile, mediaType: string) => void;
enabled: boolean;
orientation: string;
}
export const RecordingButton: React.FC<RecordingButtonProps> = ({
@ -24,6 +25,7 @@ export const RecordingButton: React.FC<RecordingButtonProps> = ({
camera,
onMediaCaptured,
enabled,
orientation,
}) => {
const isRecording = useRef(false);
// UseRef won't trigger a re-render
@ -54,6 +56,7 @@ export const RecordingButton: React.FC<RecordingButtonProps> = ({
throw new Error("Camera ref is null!"); // Error handling could be more graceful
}
console.log("calling startRecording()...");
console.log(`with ${orientation}`);
camera.current.startRecording({
onRecordingError: (error) => {
console.error("Recording failed!", error);
@ -63,6 +66,7 @@ export const RecordingButton: React.FC<RecordingButtonProps> = ({
onMediaCaptured(video, "video");
onStoppedRecording();
},
orientation: orientation,
});
console.log("called startRecording()!");
isRecording.current = true;
@ -70,7 +74,7 @@ export const RecordingButton: React.FC<RecordingButtonProps> = ({
} catch (e) {
console.error("failed to start recording!", e, "camera");
}
}, [camera, onMediaCaptured, onStoppedRecording]);
}, [camera, onMediaCaptured, onStoppedRecording, orientation]);
const handlePress = () => {
if (isRecording.current) {