diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-12-02 00:49:19 +0100 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2024-12-02 00:49:19 +0100 |
commit | 7b59425029ebcb209e07663ab7da1cedf1912661 (patch) | |
tree | 0f91b01f919dcbed12b156ee687b61e3f4eaeda8 | |
parent | d4c9e4947d794dd6cfc79199fffd85592515b6b3 (diff) |
feat: add guard for player on source change
-rw-r--r-- | src/frontend/tubo/player/events.cljs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/frontend/tubo/player/events.cljs b/src/frontend/tubo/player/events.cljs index 6350029..d189e56 100644 --- a/src/frontend/tubo/player/events.cljs +++ b/src/frontend/tubo/player/events.cljs @@ -18,9 +18,10 @@ (rf/reg-fx :player/src (fn [{:keys [player src current-pos]}] - (set! (.-src @player) (clj->js src)) - (set! (.-onended @player) - #(rf/dispatch [:queue/change-pos (inc current-pos)])))) + (when (and player @player) + (set! (.-src @player) (clj->js src)) + (set! (.-onended @player) + #(rf/dispatch [:queue/change-pos (inc current-pos)]))))) (rf/reg-fx :player/loop |