fix: sync webcam preview playback speed
This commit is contained in:
@@ -248,7 +248,11 @@ export function LaunchWindow() {
|
||||
</button>
|
||||
<button
|
||||
className={`${hudIconBtnClasses} ${webcamEnabled ? "drop-shadow-[0_0_4px_rgba(74,222,128,0.4)]" : ""}`}
|
||||
onClick={() => !recording && setWebcamEnabled(!webcamEnabled)}
|
||||
onClick={() => {
|
||||
if (!recording) {
|
||||
void setWebcamEnabled(!webcamEnabled);
|
||||
}
|
||||
}}
|
||||
disabled={recording}
|
||||
title={webcamEnabled ? "Disable webcam" : "Enable webcam"}
|
||||
>
|
||||
|
||||
@@ -968,6 +968,13 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
|
||||
return;
|
||||
}
|
||||
|
||||
const activeSpeedRegion =
|
||||
speedRegions.find(
|
||||
(region) =>
|
||||
currentTime * 1000 >= region.startMs && currentTime * 1000 < region.endMs,
|
||||
) ?? null;
|
||||
webcamVideo.playbackRate = activeSpeedRegion ? activeSpeedRegion.speed : 1;
|
||||
|
||||
if (!isPlaying) {
|
||||
webcamVideo.pause();
|
||||
if (Math.abs(webcamVideo.currentTime - currentTime) > 0.05) {
|
||||
@@ -983,7 +990,7 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
|
||||
webcamVideo.play().catch(() => {
|
||||
// Ignore webcam autoplay restoration failures.
|
||||
});
|
||||
}, [currentTime, isPlaying, webcamVideoPath]);
|
||||
}, [currentTime, isPlaying, speedRegions, webcamVideoPath]);
|
||||
|
||||
useEffect(() => {
|
||||
const webcamVideo = webcamVideoRef.current;
|
||||
|
||||
Reference in New Issue
Block a user