Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat: add pause/resume recording with duration fix

Siddharth08f66c7c2539
diff --cc src/components/launch/LaunchWindow.tsx
index d1185e80d,d6435cf02..249dd77d3
--- a/src/components/launch/LaunchWindow.tsx
+++ b/src/components/launch/LaunchWindow.tsx
@@@ -42,9 -41,10 +42,11 @@@ const ICON_CONFIG =
micOff: { icon: MdMicOff, size: ICON_SIZE },
webcamOn: { icon: MdVideocam, size: ICON_SIZE },
webcamOff: { icon: MdVideocamOff, size: ICON_SIZE },
+ pause: { icon: BsPauseCircle, size: ICON_SIZE },
+ resume: { icon: BsPlayCircle, size: ICON_SIZE },
stop: { icon: FaRegStopCircle, size: ICON_SIZE },
restart: { icon: MdRestartAlt, size: ICON_SIZE },
+ cancel: { icon: MdCancel, size: ICON_SIZE },
record: { icon: BsRecordCircle, size: ICON_SIZE },
videoFile: { icon: MdVideoFile, size: ICON_SIZE },
folder: { icon: FaFolderOpen, size: ICON_SIZE },
@@@ -79,9 -79,11 +81,12 @@@ export function LaunchWindow()
const {
recording,
+ paused,
+ elapsedSeconds,
toggleRecording,
+ togglePaused,
restartRecording,
+ cancelRecording,
microphoneEnabled,
setMicrophoneEnabled,
microphoneDeviceId,
diff --cc src/hooks/useScreenRecorder.ts
index 25adf6d23,6c8fe0942..a676d668e
--- a/src/hooks/useScreenRecorder.ts
+++ b/src/hooks/useScreenRecorder.ts
@@@ -41,9 -41,11 +41,12 @@@ const WEBCAM_TARGET_FRAME_RATE = 30
type UseScreenRecorderReturn = {
recording: boolean;
+ paused: boolean;
+ elapsedSeconds: number;
toggleRecording: () => void;
+ togglePaused: () => void;
restartRecording: () => void;
+ cancelRecording: () => void;
microphoneEnabled: boolean;
setMicrophoneEnabled: (enabled: boolean) => void;
microphoneDeviceId: string | undefined;
@@@ -602,22 -679,31 +680,43 @@@ export function useScreenRecorder(): Us
}
};
+ const cancelRecording = () => {
+ const activeScreenRecorder = screenRecorder.current;
+ if (!activeScreenRecorder || activeScreenRecorder.recorder.state !== "recording") return;
+
+ const activeRecordingId = recordingId.current;
+ discardRecordingId.current = activeRecordingId;
+ allowAutoFinalize.current = false;
+
+ stopRecording.current();
+ };
+
+ useEffect(() => {
+ if (!recording) {
+ setElapsedSeconds(0);
+ return;
+ }
+
+ setElapsedSeconds(Math.floor(getRecordingDurationMs() / 1000));
+ if (paused) {
+ return;
+ }
+
+ const interval = window.setInterval(() => {
+ setElapsedSeconds(Math.floor(getRecordingDurationMs() / 1000));
+ }, 250);
+
+ return () => window.clearInterval(interval);
+ }, [getRecordingDurationMs, paused, recording]);
+
return {
recording,
+ paused,
+ elapsedSeconds,
toggleRecording,
+ togglePaused,
restartRecording,
+ cancelRecording,
microphoneEnabled,
setMicrophoneEnabled,
microphoneDeviceId,
diff --cc src/i18n/locales/en/launch.json
index c1229cc39,eb57aefb8..cf111c437
--- a/src/i18n/locales/en/launch.json
+++ b/src/i18n/locales/en/launch.json
@@@ -3,7 -3,8 +3,9 @@@
"hideHUD": "Hide HUD",
"closeApp": "Close App",
"restartRecording": "Restart recording",
+ "cancelRecording": "Cancel recording",
+ "pauseRecording": "Pause recording",
+ "resumeRecording": "Resume recording",
"openVideoFile": "Open video file",
"openProject": "Open project"
},
diff --cc src/i18n/locales/es/launch.json
index f5be07c25,f53a92c5b..f47bc8197
--- a/src/i18n/locales/es/launch.json
+++ b/src/i18n/locales/es/launch.json
@@@ -3,7 -3,8 +3,9 @@@
"hideHUD": "Ocultar HUD",
"closeApp": "Cerrar aplicación",
"restartRecording": "Reiniciar grabación",
+ "cancelRecording": "Cancelar grabación",
+ "pauseRecording": "Pausar grabación",
+ "resumeRecording": "Reanudar grabación",
"openVideoFile": "Abrir archivo de video",
"openProject": "Abrir proyecto"
},
diff --cc src/i18n/locales/zh-CN/launch.json
index 0c2b3197f,285111ea8..6b63df190
--- a/src/i18n/locales/zh-CN/launch.json
+++ b/src/i18n/locales/zh-CN/launch.json
@@@ -3,7 -3,8 +3,9 @@@
"hideHUD": "隐藏控制面板",
"closeApp": "关闭应用",
"restartRecording": "重新开始录制",
+ "cancelRecording": "取消录制",
+ "pauseRecording": "暂停录制",
+ "resumeRecording": "继续录制",
"openVideoFile": "打开视频文件",
"openProject": "打开项目"
},