fix: read live video.currentTime for rapid frame steps and add JSDoc
- Read currentTime directly from the video element instead of the React ref so rapid arrow key presses each advance by exactly one frame - Add JSDoc docstrings to frameStep.ts exports
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user