Revert "fix: play from the playhead, not currentTime (iOS deep-link seek)"
This reverts commit 5c58af9036.
This commit is contained in:
parent
484351746f
commit
a62af2584b
1 changed files with 11 additions and 9 deletions
|
|
@ -105,6 +105,16 @@
|
||||||
segs))
|
segs))
|
||||||
(max 0 (dec (count 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 /
|
;; 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
|
;; :on-pause (below) engage/disengage this segment-aware tick, so the native
|
||||||
;; controls and the toolbar button behave identically. `play` holds the frozen
|
;; controls and the toolbar button behave identically. `play` holds the frozen
|
||||||
|
|
@ -154,15 +164,7 @@
|
||||||
(rf/dispatch [::events/set-playhead ctx 0])
|
(rf/dispatch [::events/set-playhead ctx 0])
|
||||||
(seek-video! fps s0)
|
(seek-video! fps s0)
|
||||||
(reset! play {:ctx ctx :segs segs :fps fps :idx 0 :pending-ns 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
|
(reset! play {:ctx ctx :segs segs :fps fps :idx (seg-at-src segs (* (.-currentTime v) fps))}))
|
||||||
;; 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})))
|
|
||||||
(rf/dispatch [::events/set-playing true])
|
(rf/dispatch [::events/set-playing true])
|
||||||
(reset! raf (js/requestAnimationFrame play-tick)))))
|
(reset! raf (js/requestAnimationFrame play-tick)))))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue