Files
hyperframes/packages/studio/src/player/lib/playbackScrub.ts
T
Miguel Ángel 4dc1bee9c2 fix(studio): preview lookups use the right element when an id repeats across files (#4486)
* fix(studio): preview lookups find the element the timeline bound when an id repeats

* fix(studio): preview lookups prefer the element's own file, and a pasted element gets its own hf-id

* fix(studio): scrub audio, panel reads and gestures act on the bound element, one scan per pass

* refactor(studio): one owner for the selected node lookup, and scrub indexes only audio

* fix(studio): the panel's tween list matches class tweens against the selected element itself
2026-09-25 11:42:10 +00:00

17 lines
845 B
TypeScript

import { usePlayerStore } from "../store/playerStore";
import { scrubPreviewAudio, stopScrubPreviewAudio } from "./timelineIframeHelpers";
import { getTimelineElementIndexes } from "./timelineElementIndexes";
export { stopScrubPreviewAudio };
// Scrub the music track's audio at a seeked composition time (paused-seek only).
// Skipped when audio is muted or the time falls outside the music clip.
export function scrubMusicAtSeek(iframe: HTMLIFrameElement | null, nextTime: number): void {
const s = usePlayerStore.getState();
const music = getTimelineElementIndexes(s.elements).musicElement;
if (!music || s.audioMuted) return;
const rel = nextTime - music.start;
const audioFileTime = rel >= 0 && rel <= music.duration ? (music.playbackStart ?? 0) + rel : null;
scrubPreviewAudio(iframe, audioFileTime, music, s.audioVolume);
}