diff options
| author | Vlad <vlad.palacio@gmail.com> | 2025-07-30 10:25:35 -0400 |
|---|---|---|
| committer | Vlad <vlad.palacio@gmail.com> | 2025-07-30 10:25:35 -0400 |
| commit | 281ec63d7e0dfe70534790deb790c5bbd6701502 (patch) | |
| tree | 1180cccbb9aeb6dfd03e254f98513674e895bde9 /apps/web/src/stores | |
| parent | 1c20027d33bcf303d6a9b40970cd8216c489f0d5 (diff) | |
| download | opencut-281ec63d7e0dfe70534790deb790c5bbd6701502.tar.gz | |
Fixed BUG Editor cursor does not stop at the end of an audio file
Get duration of content on the timeline to make sure the playhead moves until the end of the timeline content when the content is less than 10 seconds.
Originally it would go all the way to the 10 seconds when timeline content was less than that.
I checked how clipchamp does it and they have a min 10 sec timeline but video timeline plays at length of content, so we are doing it like the pros. timeline is jumpy though will probably work on that.
Diffstat (limited to 'apps/web/src/stores')
| -rw-r--r-- | apps/web/src/stores/playback-store.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/apps/web/src/stores/playback-store.ts b/apps/web/src/stores/playback-store.ts index 543865f9..70ff490d 100644 --- a/apps/web/src/stores/playback-store.ts +++ b/apps/web/src/stores/playback-store.ts @@ -20,8 +20,20 @@ const startTimer = (store: () => PlaybackStore) => { lastUpdate = now; const newTime = state.currentTime + delta * state.speed; - if (newTime >= state.duration) { - // When video completes, pause and reset playhead to start + + // Get actual content duration from timeline store + const { useTimelineStore } = require("@/stores/timeline-store"); + const actualContentDuration = useTimelineStore + .getState() + .getTotalDuration(); + + // Stop at actual content end, not timeline duration (which has 10s minimum) + // It was either this or reducing default min timeline to 1 second + const effectiveDuration = + actualContentDuration > 0 ? actualContentDuration : state.duration; + + if (newTime >= effectiveDuration) { + // When content completes, pause and reset playhead to start state.pause(); state.setCurrentTime(0); // Notify video elements to sync with reset |
