From 7ebe45c57980627ec7fd347f4735d382cfa88b3a Mon Sep 17 00:00:00 2001 From: Miguel Ángel Moreno Date: Mon, 29 Jan 2024 21:48:36 +0100 Subject: feat(frontend): amend playback for first stream after reload --- src/frontend/tubo/components/audio_player.cljs | 6 ++++-- src/frontend/tubo/events.cljs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/frontend') diff --git a/src/frontend/tubo/components/audio_player.cljs b/src/frontend/tubo/components/audio_player.cljs index e8541a9..73cabea 100644 --- a/src/frontend/tubo/components/audio_player.cljs +++ b/src/frontend/tubo/components/audio_player.cljs @@ -12,7 +12,8 @@ (defn audio-source [!player] - (let [{:keys [stream]} @(rf/subscribe [:media-queue-stream])] + (let [{:keys [stream]} @(rf/subscribe [:media-queue-stream]) + media-queue-pos @(rf/subscribe [:media-queue-pos])] (r/create-class {:display-name "AudioPlayer" :component-did-mount @@ -29,8 +30,9 @@ [:audio {:ref #(reset! !player %) :loop (= loop-playback :stream) - :on-loaded-data #(rf/dispatch [::events/player-start]) :muted muted? + :on-loaded-data #(rf/dispatch [::events/player-start]) + :on-ended #(rf/dispatch [::events/change-media-queue-pos (+ media-queue-pos 1)]) :on-time-update #(reset! !elapsed-time (.-currentTime @!player)) :on-pause #(rf/dispatch [::events/change-player-paused true]) :on-play #(rf/dispatch [::events/change-player-paused false])}]))}))) diff --git a/src/frontend/tubo/events.cljs b/src/frontend/tubo/events.cljs index a7d5269..f960baf 100644 --- a/src/frontend/tubo/events.cljs +++ b/src/frontend/tubo/events.cljs @@ -25,6 +25,7 @@ :stream {} :search-results [] :services [] + :paused true :loop-playback (if (nil? loop-playback) :playlist loop-playback) :media-queue (if (nil? media-queue) [] media-queue) :media-queue-pos (if (nil? media-queue-pos) 0 media-queue-pos) -- cgit v1.2.3