From f7d823cd3455aa73a17c927382ea3f34f4610c23 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Tue, 10 Dec 2024 11:13:43 +0100 Subject: feat: add muted attribute to audio player and fix seek --- src/frontend/tubo/bg_player/events.cljs | 5 ++--- src/frontend/tubo/bg_player/views.cljs | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/frontend/tubo/bg_player/events.cljs b/src/frontend/tubo/bg_player/events.cljs index c82b50e..39b12d9 100644 --- a/src/frontend/tubo/bg_player/events.cljs +++ b/src/frontend/tubo/bg_player/events.cljs @@ -6,9 +6,8 @@ (rf/reg-event-fx :bg-player/seek [(rf/inject-cofx ::inject/sub [:bg-player])] - (fn [{:keys [db bg-player]} [_ time]] - (when (:bg-player/ready db) - {:player/time {:time time :player bg-player}}))) + (fn [{:keys [bg-player]} [_ time]] + {:player/time {:time time :player bg-player}})) (rf/reg-event-db :bg-player/set-paused diff --git a/src/frontend/tubo/bg_player/views.cljs b/src/frontend/tubo/bg_player/views.cljs index d554ce3..a7e511b 100644 --- a/src/frontend/tubo/bg_player/views.cljs +++ b/src/frontend/tubo/bg_player/views.cljs @@ -271,12 +271,16 @@ #(rf/dispatch [:queue/change-pos (inc queue-pos)])) (when stream (set! (.-src (rdom/dom-node this)) - (:content (nth (:audio-streams stream) 0))))) + (-> stream + :audio-streams + first + :content)))) :reagent-render (fn [!player] [:audio {:ref #(reset! !player %) :loop (= @(rf/subscribe [:player/loop]) :stream) + :muted @(rf/subscribe [:player/muted]) :on-can-play #(rf/dispatch [:bg-player/ready true]) :on-seeked #(reset! !elapsed-time (.-currentTime @!player)) :on-time-update #(reset! !elapsed-time (.-currentTime @!player)) -- cgit v1.2.3