From be940cd54cac9f19c7803fe80fe76a3f576af238 Mon Sep 17 00:00:00 2001 From: Jacques Date: Thu, 22 Jan 2026 21:19:51 +0100 Subject: [PATCH] fix(camera): default to back camera, add flip button, fix settings crash on mobile --- client/src/components/camera-recorder.tsx | 51 ++++++++++++++--------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/client/src/components/camera-recorder.tsx b/client/src/components/camera-recorder.tsx index d3e81dd..f39c476 100644 --- a/client/src/components/camera-recorder.tsx +++ b/client/src/components/camera-recorder.tsx @@ -4,7 +4,6 @@ import Webcam from 'react-webcam'; import { Camera, StopCircle, RefreshCw, CheckCircle, X, RotateCcw, Settings2, AlertCircle, Video } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { useToast } from '@/hooks/use-toast'; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; interface CameraRecorderProps { onCapture: (file: File) => void; @@ -40,6 +39,7 @@ export function CameraRecorder({ onCapture, onCancel }: CameraRecorderProps) { // Devices & Settings const [devices, setDevices] = useState([]); const [selectedDeviceId, setSelectedDeviceId] = useState(''); + const [facingMode, setFacingMode] = useState<"user" | "environment">("environment"); const [quality, setQuality] = useState('1080p'); const [showSettings, setShowSettings] = useState(false); const [cameraError, setCameraError] = useState(null); @@ -131,6 +131,11 @@ export function CameraRecorder({ onCapture, onCancel }: CameraRecorderProps) { setCameraError(msg); }, []); + const toggleCamera = () => { + setFacingMode(prev => prev === "user" ? "environment" : "user"); + setSelectedDeviceId(''); + }; + // Review Mode if (recordedBlob && previewUrl) { return ( @@ -153,7 +158,7 @@ export function CameraRecorder({ onCapture, onCancel }: CameraRecorderProps) { width: { ideal: config.width }, height: { ideal: config.height }, deviceId: selectedDeviceId ? { exact: selectedDeviceId } : undefined, - facingMode: selectedDeviceId ? undefined : "user" + facingMode: selectedDeviceId ? undefined : facingMode }; return ( @@ -173,10 +178,15 @@ export function CameraRecorder({ onCapture, onCancel }: CameraRecorderProps) { {formatTime(timer)} ) : ( - +
+ + +
)}
@@ -205,19 +215,22 @@ export function CameraRecorder({ onCapture, onCancel }: CameraRecorderProps) {
- - + + +
+ {devices.map((device, idx) => ( + + ))} +