diff --git a/frontend/src/arthur/events/playback.cljs b/frontend/src/arthur/events/playback.cljs index 994b8e8..8687a7f 100644 --- a/frontend/src/arthur/events/playback.cljs +++ b/frontend/src/arthur/events/playback.cljs @@ -63,11 +63,18 @@ (get-in db [:ui :gesture :auto-key?]) (assoc :dispatch [:arthur.events.ui/record-gesture f]))))) -(rf/reg-event-fx - ::play - (fn [{:keys [db]} _] - {:db (assoc-in db [:playback :playing?] true) - ::play-from! [(fps db) (frames db) (get-in db [:playback :frame] 0)]})) +(defn- start + "Play from the playhead, or from the top when the playhead is on the last + frame. Playing the last frame alone is a twenty-fourth of a second and then + silence, so play there looked like a button that did nothing." + [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 ::pause @@ -80,8 +87,7 @@ (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-from! [(fps db) (frames db) (get-in db [:playback :frame] 0)]}))) + (start db)))) (rf/reg-event-fx ::seek