mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 19:36:04 +00:00
fix(studio): address work-area edge cases from review
- setInPoint/setOutPoint now cross-clear the opposite marker when setting one would produce an inverted range (in >= out), preventing the invalid state rather than correcting it at tick time - Forward tick no longer gates on !adapter.isPlaying() — outPoint crossing fires even while the adapter is running; explicitly pauses on the non-loop path so playback stops at out-point rather than sailing to dur - play() end-of-stream reset seeks to inPoint (if set) instead of hardcoded 0
This commit is contained in:
@@ -190,7 +190,7 @@ export function useTimelinePlayer() {
|
||||
const rawLoopStart = inPoint !== null ? inPoint : 0;
|
||||
const loopEnd = rawLoopStart < rawLoopEnd ? rawLoopEnd : dur;
|
||||
const loopStart = rawLoopStart < rawLoopEnd ? rawLoopStart : 0;
|
||||
if (time >= loopEnd && !adapter.isPlaying()) {
|
||||
if (time >= loopEnd) {
|
||||
if (usePlayerStore.getState().loopEnabled && dur > 0) {
|
||||
adapter.seek(loopStart);
|
||||
liveTime.notify(loopStart);
|
||||
@@ -199,6 +199,7 @@ export function useTimelinePlayer() {
|
||||
rafRef.current = requestAnimationFrame(tick);
|
||||
return;
|
||||
}
|
||||
if (adapter.isPlaying()) adapter.pause();
|
||||
setCurrentTime(time); // sync Zustand once at end
|
||||
setIsPlaying(false);
|
||||
cancelAnimationFrame(rafRef.current);
|
||||
@@ -246,7 +247,7 @@ export function useTimelinePlayer() {
|
||||
const adapter = getAdapter();
|
||||
if (!adapter) return;
|
||||
if (adapter.getTime() >= adapter.getDuration()) {
|
||||
adapter.seek(0);
|
||||
adapter.seek(usePlayerStore.getState().inPoint ?? 0);
|
||||
}
|
||||
unmutePreviewMedia(iframeRef.current);
|
||||
applyPlaybackRate(usePlayerStore.getState().playbackRate);
|
||||
|
||||
@@ -113,8 +113,23 @@ export const usePlayerStore = create<PlayerState>((set) => ({
|
||||
},
|
||||
setLoopEnabled: (enabled) => set({ loopEnabled: enabled }),
|
||||
setZoomMode: (mode) => set({ zoomMode: mode }),
|
||||
setInPoint: (time) => set({ inPoint: time !== null && Number.isFinite(time) ? time : null }),
|
||||
setOutPoint: (time) => set({ outPoint: time !== null && Number.isFinite(time) ? time : null }),
|
||||
setInPoint: (time) =>
|
||||
set((state) => {
|
||||
const t = time !== null && Number.isFinite(time) ? time : null;
|
||||
return {
|
||||
inPoint: t,
|
||||
outPoint:
|
||||
t !== null && state.outPoint !== null && t >= state.outPoint ? null : state.outPoint,
|
||||
};
|
||||
}),
|
||||
setOutPoint: (time) =>
|
||||
set((state) => {
|
||||
const t = time !== null && Number.isFinite(time) ? time : null;
|
||||
return {
|
||||
outPoint: t,
|
||||
inPoint: t !== null && state.inPoint !== null && t <= state.inPoint ? null : state.inPoint,
|
||||
};
|
||||
}),
|
||||
setManualZoomPercent: (percent) =>
|
||||
set({ manualZoomPercent: Math.max(10, Math.min(2000, Math.round(percent))) }),
|
||||
setCurrentTime: (time) => set({ currentTime: Number.isFinite(time) ? time : 0 }),
|
||||
|
||||
Reference in New Issue
Block a user