From 981bef98f9b48527d9a9decd406a3b823e48ffa8 Mon Sep 17 00:00:00 2001 From: Olive Vaughn Date: Sun, 4 Oct 2026 00:48:43 -0400 Subject: [PATCH] Start playback at the playhead --- frontend/src/arthur/events/playback.cljs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/arthur/events/playback.cljs b/frontend/src/arthur/events/playback.cljs index 59c78c6..1bb005c 100644 --- a/frontend/src/arthur/events/playback.cljs +++ b/frontend/src/arthur/events/playback.cljs @@ -67,7 +67,7 @@ ::play (fn [{:keys [db]} _] {:db (assoc-in db [:playback :playing?] true) - ::play! nil})) + ::play-from! [(fps db) (frames db) (get-in db [:playback :frame] 0)]})) (rf/reg-event-fx ::pause @@ -80,7 +80,8 @@ (fn [{:keys [db]} _] (if (get-in db [:playback :playing?]) {:db (assoc-in db [:playback :playing?] false) ::pause! nil} - {:db (assoc-in db [:playback :playing?] true) ::play! nil}))) + {:db (assoc-in db [:playback :playing?] true) + ::play-from! [(fps db) (frames db) (get-in db [:playback :frame] 0)]}))) (rf/reg-event-fx ::seek @@ -103,6 +104,13 @@ ;; --- effects: every DOM touch on the audio element is one of these --- (rf/reg-fx ::play! (fn [_] (clock/play!))) +(rf/reg-fx ::play-from! + (fn [[fps frames f]] + ;; The transport is the audio clock; app-db's frame is the visible + ;; playhead. Re-anchor before starting so Play always honors the frame + ;; currently shown, including after the clock has reached the clip end. + (clock/seek! fps frames f) + (clock/play!))) (rf/reg-fx ::pause! (fn [_] (clock/pause!))) (rf/reg-fx ::rate! (fn [r] (clock/set-rate! r))) (rf/reg-fx ::seek! (fn [[fps frames f]] (clock/seek! fps frames f)))