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:
Ivan Malison 2024-02-08 11:34:19 -07:00
commit 0c89178542
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} camera={camera}
onMediaCaptured={onMediaCaptured} onMediaCaptured={onMediaCaptured}
enabled={isCameraInitialized} enabled={isCameraInitialized}
orientation={orientation}
/> />
<View <View
style={[ style={[

View File

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