fix(studio): clamp playhead to composition duration in RAF loop

The studio player's RAF loop in useTimelinePlayer notified the playhead
position via liveTime.notify(time) before checking the duration limit.
When adapter.getTime() returned a value past the composition's
data-duration (due to timing drift or delayed duration calculation),
the playhead would visually overshoot — showing e.g. 0:19 on a 0:10
composition.

The web player component already had this clamping (playback-state.ts
line 42, direct-timeline-clock.ts line 56), but the studio player's
forward loop was missing it.

Fix: clamp time to dur before notifying, matching the pattern already
used in the web player: Math.min(rawTime, dur) when dur > 0.
This commit is contained in:
Miguel Ángel
2026-05-25 19:18:46 -04:00
parent 9a4a00582c
commit 1aaf89ce70
@@ -226,8 +226,9 @@ export function useTimelinePlayer() {
const tick = () => {
const adapter = getAdapter();
if (adapter) {
const time = adapter.getTime();
const rawTime = adapter.getTime();
const dur = adapter.getDuration();
const time = dur > 0 ? Math.min(rawTime, dur) : rawTime;
liveTime.notify(time); // direct DOM updates, no React re-render
const { inPoint, outPoint } = usePlayerStore.getState();
const rawLoopEnd = outPoint !== null ? outPoint : dur;