Skip to content

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

fix: read live video.currentTime for rapid frame steps and add JSDoc

theaiagent3bfcd8576b43
diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsx
index 3efd9cea3..e83f5b0c2 100644
--- a/src/components/video-editor/VideoEditor.tsx
+++ b/src/components/video-editor/VideoEditor.tsx
@@ -949,13 +949,17 @@ export default function VideoEditor() {
return;
}
e.preventDefault();
+ const video = videoPlaybackRef.current?.video;
+ if (!video) {
+ return;
+ }
const direction = e.key === "ArrowLeft" ? "backward" : "forward";
const newTime = computeFrameStepTime(
- currentTimeRef.current,
- durationRef.current,
+ video.currentTime,
+ Number.isFinite(video.duration) ? video.duration : durationRef.current,
direction,
);
- handleSeek(newTime);
+ video.currentTime = newTime;
return;
}
diff --git a/src/lib/frameStep.ts b/src/lib/frameStep.ts
index 7eaaf6bcc..dc42d78cb 100644
--- a/src/lib/frameStep.ts
+++ b/src/lib/frameStep.ts
@@ -1,5 +1,10 @@
+/** Duration of a single frame in seconds at 60 FPS (~16.67ms). */
export const FRAME_DURATION_SEC = 1 / 60;
+/**
+ * Compute the new playhead time after stepping one frame forward or backward.
+ * The result is clamped to the range [0, duration].
+ */
export function computeFrameStepTime(
currentTime: number,
duration: number,