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
refactor(speed): reuse clampPlaybackSpeed, narrow the parser signature
Etienne Lescot63fe45e70665
diff --git a/src/components/video-editor/customPlaybackSpeed.ts b/src/components/video-editor/customPlaybackSpeed.tsindex b3c71e680..03a16cae3 100644--- a/src/components/video-editor/customPlaybackSpeed.ts+++ b/src/components/video-editor/customPlaybackSpeed.ts@@ -1,4 +1,9 @@-import { MAX_PLAYBACK_SPEED, MIN_PLAYBACK_SPEED, type PlaybackSpeed } from "./types";+import {+ clampPlaybackSpeed,+ MAX_PLAYBACK_SPEED,+ MIN_PLAYBACK_SPEED,+ type PlaybackSpeed,+} from "./types";export type CustomPlaybackSpeedInputResult =| { status: "empty"; draft: string }@@ -6,13 +11,8 @@ export type CustomPlaybackSpeedInputResult =| { status: "too-slow"; draft: string }| { status: "valid"; draft: string; speed: PlaybackSpeed };-export function parseCustomPlaybackSpeedInput(- rawValue: string | null | undefined,-): CustomPlaybackSpeedInputResult {- const draft = rawValue ?? "";+export function parseCustomPlaybackSpeedInput(draft: string): CustomPlaybackSpeedInputResult {const normalized = Number(draft.replace(/,/g, "."));- const n =- Math.round(Math.min(MAX_PLAYBACK_SPEED, Math.max(MIN_PLAYBACK_SPEED, normalized)) * 100) / 100;if (!Number.isFinite(normalized)) {return { status: "empty", draft };@@ -23,5 +23,8 @@ export function parseCustomPlaybackSpeedInput(if (normalized < MIN_PLAYBACK_SPEED) {return { status: "too-slow", draft };}- return { status: "valid", draft, speed: n };+ // Reuse the shared clamp rather than re-inlining its rounding rule: this+ // value feeds the native scene, and a second copy would drift the first time+ // the bounds or the 2-decimal step change.+ return { status: "valid", draft, speed: clampPlaybackSpeed(normalized) };}