From 27b789de62f06f86b2624ecb0c59ce1674c6c2be Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Wed, 29 May 2024 19:38:28 +0200 Subject: feat: decouple slider color application from playback start --- src/frontend/tubo/player/events.cljs | 8 ++++++-- src/frontend/tubo/player/views.cljs | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/frontend') 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 @@ -87,12 +87,16 @@ (doseq [class [".vjs-play-progress" ".vjs-volume-level" ".vjs-slider-bar"]] (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])}))) -- cgit v1.2.3