Skip to content

Commit e6de8a0

Browse files
committed
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
1 parent c7eefdf commit e6de8a0

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

packages/studio/src/player/hooks/useTimelinePlayer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export function useTimelinePlayer() {
190190
const rawLoopStart = inPoint !== null ? inPoint : 0;
191191
const loopEnd = rawLoopStart < rawLoopEnd ? rawLoopEnd : dur;
192192
const loopStart = rawLoopStart < rawLoopEnd ? rawLoopStart : 0;
193-
if (time >= loopEnd && !adapter.isPlaying()) {
193+
if (time >= loopEnd) {
194194
if (usePlayerStore.getState().loopEnabled && dur > 0) {
195195
adapter.seek(loopStart);
196196
liveTime.notify(loopStart);
@@ -199,6 +199,7 @@ export function useTimelinePlayer() {
199199
rafRef.current = requestAnimationFrame(tick);
200200
return;
201201
}
202+
if (adapter.isPlaying()) adapter.pause();
202203
setCurrentTime(time); // sync Zustand once at end
203204
setIsPlaying(false);
204205
cancelAnimationFrame(rafRef.current);
@@ -246,7 +247,7 @@ export function useTimelinePlayer() {
246247
const adapter = getAdapter();
247248
if (!adapter) return;
248249
if (adapter.getTime() >= adapter.getDuration()) {
249-
adapter.seek(0);
250+
adapter.seek(usePlayerStore.getState().inPoint ?? 0);
250251
}
251252
unmutePreviewMedia(iframeRef.current);
252253
applyPlaybackRate(usePlayerStore.getState().playbackRate);

packages/studio/src/player/store/playerStore.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,23 @@ export const usePlayerStore = create<PlayerState>((set) => ({
113113
},
114114
setLoopEnabled: (enabled) => set({ loopEnabled: enabled }),
115115
setZoomMode: (mode) => set({ zoomMode: mode }),
116-
setInPoint: (time) => set({ inPoint: time !== null && Number.isFinite(time) ? time : null }),
117-
setOutPoint: (time) => set({ outPoint: time !== null && Number.isFinite(time) ? time : null }),
116+
setInPoint: (time) =>
117+
set((state) => {
118+
const t = time !== null && Number.isFinite(time) ? time : null;
119+
return {
120+
inPoint: t,
121+
outPoint:
122+
t !== null && state.outPoint !== null && t >= state.outPoint ? null : state.outPoint,
123+
};
124+
}),
125+
setOutPoint: (time) =>
126+
set((state) => {
127+
const t = time !== null && Number.isFinite(time) ? time : null;
128+
return {
129+
outPoint: t,
130+
inPoint: t !== null && state.inPoint !== null && t <= state.inPoint ? null : state.inPoint,
131+
};
132+
}),
118133
setManualZoomPercent: (percent) =>
119134
set({ manualZoomPercent: Math.max(10, Math.min(2000, Math.round(percent))) }),
120135
setCurrentTime: (time) => set({ currentTime: Number.isFinite(time) ? time : 0 }),

0 commit comments

Comments
 (0)