fix(lab): make replay pause authoritative
This commit is contained in:
@@ -40,6 +40,23 @@ export function advanceRecordedEvidencePlayback(
|
||||
return { ...playback, currentSeconds: clampRecordedEvidenceSeconds(next, range) };
|
||||
}
|
||||
|
||||
export function synchronizeRecordedEvidencePlayback(
|
||||
current: RecordedObservationPlayback,
|
||||
observed: RecordedObservationPlayback,
|
||||
range: RecordedEvidencePlaybackRange,
|
||||
): RecordedObservationPlayback {
|
||||
const currentSeconds = clampRecordedEvidenceSeconds(observed.currentSeconds, range);
|
||||
return {
|
||||
...current,
|
||||
currentSeconds,
|
||||
// The transport button owns play/pause intent. A native frame callback may
|
||||
// still report the previous media state immediately after an operator
|
||||
// command, so it must not restart playback. The sealed end is the only
|
||||
// media-clock transition allowed to stop the shared LAB clock.
|
||||
playing: currentSeconds >= range.endSeconds ? false : current.playing,
|
||||
};
|
||||
}
|
||||
|
||||
export function useRecordedEvidencePlayback(
|
||||
range: RecordedEvidencePlaybackRange | null,
|
||||
{ clock = "animation" }: { clock?: "animation" | "external" } = {},
|
||||
@@ -106,11 +123,7 @@ export function useRecordedEvidencePlayback(
|
||||
|
||||
const synchronize = useCallback((next: RecordedObservationPlayback) => {
|
||||
if (!validRange(range) || !Number.isFinite(next.currentSeconds)) return;
|
||||
setPlayback((current) => ({
|
||||
...current,
|
||||
currentSeconds: clampRecordedEvidenceSeconds(next.currentSeconds, range),
|
||||
playing: next.playing,
|
||||
}));
|
||||
setPlayback((current) => synchronizeRecordedEvidencePlayback(current, next, range));
|
||||
}, [range]);
|
||||
|
||||
return useMemo(() => ({
|
||||
|
||||
Reference in New Issue
Block a user