Skip to content

Write HTML. Render video. Built for agents.

fix(studio): uncap seek clamp to include timeline element range

Miguel Ángel1a4e534d0fdb
diff --git a/packages/studio/src/player/hooks/useTimelinePlayer.ts b/packages/studio/src/player/hooks/useTimelinePlayer.ts
index 7b6579afed..cecd984581 100644
--- a/packages/studio/src/player/hooks/useTimelinePlayer.ts
+++ b/packages/studio/src/player/hooks/useTimelinePlayer.ts
@@ -357,7 +357,13 @@ export function useTimelinePlayer() {
pendingSeekRef.current = Math.max(0, time);
return false;
}
- const duration = Math.max(0, adapter.getDuration());
+ const adapterDur = adapter.getDuration();
+ const state = usePlayerStore.getState();
+ const maxEnd =
+ state.elements.length > 0
+ ? Math.max(...state.elements.map((el) => el.start + el.duration))
+ : 0;
+ const duration = Math.max(0, adapterDur, maxEnd);
const nextTime = Math.max(0, duration > 0 ? Math.min(duration, time) : time);
adapter.seek(nextTime, options);
liveTime.notify(nextTime); // Direct DOM updates (playhead, timecode, progress) — no re-render