1
0
Fork 0
mirror of https://github.com/heyarne/airsonic-ui.git synced 2026-05-07 02:33:39 +02:00

Pause current track when starting next, implement play / pause

This commit is contained in:
Arne Schlüter 2018-04-22 01:19:19 +02:00
commit 4639f4ef27
3 changed files with 9 additions and 7 deletions

View file

@ -20,16 +20,19 @@
(doseq [event ["loadstart" "progress" "play" "timeupdate" "pause"]]
(.addEventListener el event #(re-frame/dispatch [:audio-update (->status el)]))))
(re-frame/reg-fx
:play-song
(fn [song-url]
(some-> @current-audio .pause)
(let [audio (js/Audio. song-url)]
(reset! current-audio audio)
(attach-listeners! audio)
(.play audio))))
(re-frame/reg-fx
:pause-song
:toggle-play-pause
(fn [_]
(some-> @current-audio .pause)))
(when-let [a @current-audio]
(if (.-paused a)
(.play a)
(.pause a)))))