aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2024-05-29 19:38:28 +0200
committerMiguel Ángel Moreno <mail@migalmoreno.com>2024-05-29 19:38:28 +0200
commit27b789de62f06f86b2624ecb0c59ce1674c6c2be (patch)
treedd6f730556fcf3e9604c073d361e862b6c8e7cc0
parent9769d6275d1c7df7afa21cd34cd60e1a8f4682ea (diff)
feat: decouple slider color application from playback start
-rw-r--r--src/frontend/tubo/player/events.cljs8
-rw-r--r--src/frontend/tubo/player/views.cljs6
2 files changed, 10 insertions, 4 deletions
diff --git a/src/frontend/tubo/player/events.cljs b/src/frontend/tubo/player/events.cljs
index c7d1a1c..70bb0cc 100644
--- a/src/frontend/tubo/player/events.cljs
+++ b/src/frontend/tubo/player/events.cljs
@@ -88,11 +88,15 @@
(set! (.. (.$ (.getChild ^videojs/VideoJsPlayer @player "ControlBar") class) -style -background) color))))
(rf/reg-event-fx
+ :player/set-slider-color
+ (fn [_ [_ !player service-id]]
+ {:slider-color {:player !player :color (utils/get-service-color service-id)}}))
+
+(rf/reg-event-fx
:player/start-in-main
[(rf/inject-cofx ::inject/sub [:elapsed-time])]
(fn [{:keys [db]} [_ !player options service-id]]
- {:fx [[:audio-poster-mode {:player !player :options options}]
- [:slider-color {:player !player :color (utils/get-service-color service-id)}]]}))
+ {:fx [[:audio-poster-mode {:player !player :options options}]]}))
(rf/reg-fx
:media-session-metadata
diff --git a/src/frontend/tubo/player/views.cljs b/src/frontend/tubo/player/views.cljs
index 9196348..d7b851d 100644
--- a/src/frontend/tubo/player/views.cljs
+++ b/src/frontend/tubo/player/views.cljs
@@ -176,7 +176,9 @@
(fn [^videojs/VideoJsPlayer this]
(VideojsQualitySelector videojs)
(reset! !player (videojs (rdom/dom-node this) (clj->js options)))
- (.on @!player "ready" #(.mobileUi ^videojs/VideoJsPlayer @!player))
- (.on @!player "play" #(rf/dispatch [:player/start-in-main !player options service-id])))
+ (.on @!player "ready" (fn []
+ (.mobileUi ^videojs/VideoJsPlayer @!player)
+ (rf/dispatch [:player/set-slider-color !player service-id])))
+ (.on @!player "play" #(rf/dispatch [:player/start-in-main !player options])))
:component-will-unmount #(when @!player (.dispose @!player))
:reagent-render (fn [options] [:video-js.vjs-tubo])})))