Revert "fix: play from the playhead, not currentTime (iOS deep-link seek)"

This reverts commit 5c58af9036.
This commit is contained in:
Your Name 2026-06-30 11:17:42 -04:00
parent 484351746f
commit a62af2584b

View file

@ -105,6 +105,16 @@
segs))
(max 0 (dec (count segs)))))
(defn- seg-at-src
"Index of the segment whose SOURCE range contains source frame `sf` (0 if none)."
[segs sf]
(or (first (keep-indexed (fn [i {[a b] :src}]
(when (or (and (<= a sf) (< sf b))
(< sf a))
i))
segs))
(max 0 (dec (count segs)))))
;; The <video> element is the source of truth for play/pause. Its :on-play /
;; :on-pause (below) engage/disengage this segment-aware tick, so the native
;; controls and the toolbar button behave identically. `play` holds the frozen
@ -154,15 +164,7 @@
(rf/dispatch [::events/set-playhead ctx 0])
(seek-video! fps s0)
(reset! play {:ctx ctx :segs segs :fps fps :idx 0 :pending-ns s0}))
;; Start from the PLAYHEAD, not currentTime: on iOS a deep-linked pre-seek
;; often hasn't stuck (the element doesn't load until this very tap), so
;; currentTime is still 0 and playback would start from the top. Re-seek
;; here — inside the user gesture, where it's reliable — and drive from the
;; playhead. For ordinary pause/resume the playhead already equals
;; currentTime, so this seeks to the same spot (a no-op).
(let [src (scene/local->source segs ph)]
(seek-video! fps src)
(reset! play {:ctx ctx :segs segs :fps fps :idx (seg-at segs ph) :pending-ns src})))
(reset! play {:ctx ctx :segs segs :fps fps :idx (seg-at-src segs (* (.-currentTime v) fps))}))
(rf/dispatch [::events/set-playing true])
(reset! raf (js/requestAnimationFrame play-tick)))))