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:
parent
491c172ae7
commit
4639f4ef27
3 changed files with 9 additions and 7 deletions
|
|
@ -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)))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue