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(editor): fix annotation placeholder text and post-reload duration cap

Etienne Lescot5cfdeb3cf0ee
diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsx
index f0bfbd3fe..4954d355f 100644
--- a/src/components/video-editor/VideoEditor.tsx
+++ b/src/components/video-editor/VideoEditor.tsx
@@ -404,6 +404,11 @@ export default function VideoEditor() {
} catch {
// no-op
}
+ // This inferred duration is only a placeholder until the video element's real
+ // metadata resolves (see VideoPlayback's syncResolvedDuration). Reset its memoized
+ // last-resolved-duration guard so that resolution isn't skipped just because the
+ // real duration happens to match a value already seen from before this load.
+ videoPlaybackRef.current?.resetDurationResolution();
setIsPlaying(false);
setCurrentTime(0);
setDuration(inferredDurationMs > 0 ? inferredDurationMs / 1000 : 0);
@@ -1477,7 +1482,7 @@ export default function VideoEditor() {
startMs: Math.round(span.start),
endMs: Math.round(span.end),
type: "text",
- content: "Enter text...",
+ content: "",
position: { ...DEFAULT_ANNOTATION_POSITION },
size: { ...DEFAULT_ANNOTATION_SIZE },
style: { ...DEFAULT_ANNOTATION_STYLE },
@@ -1616,7 +1621,7 @@ export default function VideoEditor() {
if (region.id !== id) return region;
const updatedRegion = { ...region, type };
if (type === "text") {
- updatedRegion.content = region.textContent || "Enter text...";
+ updatedRegion.content = region.textContent || "";
} else if (type === "image") {
updatedRegion.content = region.imageContent || "";
} else if (type === "figure") {
diff --git a/src/components/video-editor/VideoPlayback.tsx b/src/components/video-editor/VideoPlayback.tsx
index 8b7f2e829..1acc0fa49 100644
--- a/src/components/video-editor/VideoPlayback.tsx
+++ b/src/components/video-editor/VideoPlayback.tsx
@@ -165,6 +165,14 @@ export interface VideoPlaybackRef {
containerRef: React.RefObject<HTMLDivElement>;
play: () => Promise<void>;
pause: () => void;
+ /**
+ * Clears the memoized last-resolved-duration guard so the next metadata load
+ * re-syncs `duration` even if the video's real (resolved) duration happens to
+ * match a value already seen — needed when a caller (e.g. loading a saved
+ * project) sets `duration` to something else in between, which the guard has
+ * no other way to detect.
+ */
+ resetDurationResolution: () => void;
}
function getResolvedVideoDuration(video: HTMLVideoElement): number | null {
@@ -695,6 +703,9 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
video.pause();
supplementalAudioRef.current?.pause();
},
+ resetDurationResolution: () => {
+ lastResolvedDurationRef.current = null;
+ },
}));
const updateFocusFromClientPoint = (clientX: number, clientY: number) => {