Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix: addresses review - differentiate webcam error types and handle stream acquisition
dheerajmr01954b99e962dd
diff --git a/.gitignore b/.gitignoreindex 70cc387dd..199ff4492 100644--- a/.gitignore+++ b/.gitignore@@ -25,6 +25,7 @@ dist-ssr*.sw?release/***.kiro/+.claude/# npx electron-builder --mac --win# Playwrightdiff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.tsindex ba95e60f3..8448b8202 100644--- a/src/hooks/useScreenRecorder.ts+++ b/src/hooks/useScreenRecorder.ts@@ -103,6 +103,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {const allowAutoFinalize = useRef(false);const discardRecordingId = useRef<number | null>(null);const restarting = useRef(false);+ const webcamReady = useRef(false);const selectMimeType = () => {const preferred = [@@ -182,6 +183,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {let cancelled = false;let acquiredStream: MediaStream | null = null;+ webcamReady.current = false;const acquire = async () => {try {@@ -217,11 +219,21 @@ export function useScreenRecorder(): UseScreenRecorderReturn {};});webcamStream.current = stream;+ webcamReady.current = true;} catch (cameraError) {if (!cancelled) {console.warn("Failed to get webcam access:", cameraError);setWebcamEnabledState(false);- toast.error(t("recording.cameraBlocked"));+ const isDeviceError =+ cameraError instanceof DOMException &&+ [+ "NotFoundError",+ "DevicesNotFoundError",+ "OverconstrainedError",+ "NotReadableError",+ ].includes(cameraError.name);+ toast.error(t(isDeviceError ? "recording.cameraNotFound" : "recording.cameraBlocked"));+ webcamReady.current = true;}}};@@ -230,6 +242,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {return () => {cancelled = true;+ webcamReady.current = false;if (acquiredStream) {acquiredStream.getTracks().forEach((track) => track.stop());webcamStream.current = null;@@ -464,9 +477,26 @@ export function useScreenRecorder(): UseScreenRecorderReturn {}}- if (webcamEnabled && !webcamStream.current) {- setWebcamEnabledState(false);- toast.error(t("recording.cameraDenied"));+ if (webcamEnabled) {+ if (!webcamReady.current) {+ await new Promise<void>((resolve) => {+ const interval = setInterval(() => {+ if (webcamReady.current) {+ clearInterval(interval);+ resolve();+ }+ }, 50);+ setTimeout(() => {+ clearInterval(interval);+ resolve();+ }, 5000);+ });+ }+ if (!webcamStream.current) {+ // The useEffect already showed the appropriate error toast+ // (cameraNotFound or cameraBlocked), so just disable the state.+ setWebcamEnabledState(false);+ }}stream.current = new MediaStream();diff --git a/src/i18n/locales/en/editor.json b/src/i18n/locales/en/editor.jsonindex 8acd181a5..e0cf4fd20 100644--- a/src/i18n/locales/en/editor.json+++ b/src/i18n/locales/en/editor.json@@ -31,6 +31,7 @@"microphoneDenied": "Microphone access denied. Recording will continue without audio.","cameraDenied": "Camera access denied. Recording will continue without webcam.","cameraDisconnected": "Webcam disconnected.",+ "cameraNotFound": "Camera not found.","permissionDenied": "Recording permission denied. Please allow screen recording."}}diff --git a/src/i18n/locales/es/editor.json b/src/i18n/locales/es/editor.jsonindex 5834622e6..7956b7550 100644--- a/src/i18n/locales/es/editor.json+++ b/src/i18n/locales/es/editor.json@@ -31,6 +31,7 @@"microphoneDenied": "Acceso al micrófono denegado. La grabación continuará sin audio.","cameraDenied": "Acceso a la cámara denegado. La grabación continuará sin cámara web.","cameraDisconnected": "Cámara web desconectada.",+ "cameraNotFound": "Cámara no encontrada.","permissionDenied": "Permiso de grabación denegado. Por favor permite la grabación de pantalla."}}diff --git a/src/i18n/locales/zh-CN/editor.json b/src/i18n/locales/zh-CN/editor.jsonindex 0723c88ea..2360fe875 100644--- a/src/i18n/locales/zh-CN/editor.json+++ b/src/i18n/locales/zh-CN/editor.json@@ -31,6 +31,7 @@"microphoneDenied": "麦克风权限被拒绝。录制将继续,但不包含音频。","cameraDenied": "摄像头权限被拒绝。录制将继续,但不包含摄像头画面。","cameraDisconnected": "摄像头已断开连接。",+ "cameraNotFound": "未找到摄像头。","permissionDenied": "录屏权限被拒绝。请允许屏幕录制。"}}