Merge pull request 'Properly support orientation in recorded video' (#106) from ivan/orientation into master

Reviewed-on: railbird/railbird-mobile#106
This commit is contained in:
2024-02-08 11:34:19 -07:00
3 changed files with 7 additions and 2 deletions

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) {