Play from the last frame starts over, rather than playing one frame

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Olive Vaughn 2026-10-10 20:02:42 -04:00
parent c359ac650f
commit fcf2e20f78

View file

@ -63,11 +63,18 @@
(get-in db [:ui :gesture :auto-key?]) (get-in db [:ui :gesture :auto-key?])
(assoc :dispatch [:arthur.events.ui/record-gesture f]))))) (assoc :dispatch [:arthur.events.ui/record-gesture f])))))
(rf/reg-event-fx (defn- start
::play "Play from the playhead, or from the top when the playhead is on the last
(fn [{:keys [db]} _] frame. Playing the last frame alone is a twenty-fourth of a second and then
{:db (assoc-in db [:playback :playing?] true) silence, so play there looked like a button that did nothing."
::play-from! [(fps db) (frames db) (get-in db [:playback :frame] 0)]})) [db]
(let [n (frames db)
f (get-in db [:playback :frame] 0)
f (if (< f (dec n)) f 0)]
{:db (update db :playback assoc :playing? true :frame f)
::play-from! [(fps db) n f]}))
(rf/reg-event-fx ::play (fn [{:keys [db]} _] (start db)))
(rf/reg-event-fx (rf/reg-event-fx
::pause ::pause
@ -80,8 +87,7 @@
(fn [{:keys [db]} _] (fn [{:keys [db]} _]
(if (get-in db [:playback :playing?]) (if (get-in db [:playback :playing?])
{:db (assoc-in db [:playback :playing?] false) ::pause! nil} {:db (assoc-in db [:playback :playing?] false) ::pause! nil}
{:db (assoc-in db [:playback :playing?] true) (start db))))
::play-from! [(fps db) (frames db) (get-in db [:playback :frame] 0)]})))
(rf/reg-event-fx (rf/reg-event-fx
::seek ::seek