Skip to content

OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.

TypeScript

fix(timeline): preserve playhead position when moving or resizing clips

lvalics73f02c2714c2
diff --git a/apps/web/src/bridges/playback-bridge.ts b/apps/web/src/bridges/playback-bridge.ts
index 2d61748a..3bf65cd7 100644
--- a/apps/web/src/bridges/playback-bridge.ts
+++ b/apps/web/src/bridges/playback-bridge.ts
@@ -59,7 +59,7 @@ export class PlaybackBridge {
switch (event.type) {
case "timeupdate":
- if (!this.playbackController?.getIsScrubbing()) {
+ if (!this.isUpdatingProject && !this.playbackController?.getIsScrubbing()) {
timelineStore.setPlayheadPosition(event.time);
}
break;
@@ -132,6 +132,8 @@ export class PlaybackBridge {
this.isUpdatingProject = false;
this.playbackController.scrubTo(currentTime);
+ // Explicitly restore position — scrubTo may be blocked by isScrubbing
+ timelineStore.setPlayheadPosition(currentTime);
if (wasPlaying) {
this.playbackController.play();
}
@@ -221,7 +223,9 @@ export class PlaybackBridge {
if (this.playbackController) {
this.playbackController.stop();
}
- useTimelineStore.getState().stop();
+ const store = useTimelineStore.getState();
+ store.stop();
+ store.seekToStart();
}
/**
diff --git a/apps/web/src/stores/timeline-store.ts b/apps/web/src/stores/timeline-store.ts
index 4c9ca47c..c80f78f5 100644
--- a/apps/web/src/stores/timeline-store.ts
+++ b/apps/web/src/stores/timeline-store.ts
@@ -103,10 +103,7 @@ export const useTimelineStore = create<TimelineState>()(
},
stop: () => {
- set({
- playbackState: "stopped",
- playheadPosition: 0,
- });
+ set({ playbackState: "stopped" });
},
togglePlayback: () => {