mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Can play a single song :)
This commit is contained in:
parent
9ca116ee72
commit
0e17354e58
4 changed files with 28 additions and 1 deletions
13
src/airsonic_ui/audio.cljs
Normal file
13
src/airsonic_ui/audio.cljs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
(ns airsonic-ui.audio
|
||||
(:require [re-frame.core :as re-frame]))
|
||||
|
||||
;; TODO: Manage multiple songs, buffering, stopping, progress notification...
|
||||
|
||||
(def current-audio (atom nil))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:play-song
|
||||
(fn [song-url]
|
||||
(let [audio (js/Audio. song-url)]
|
||||
(reset! current-audio audio)
|
||||
(.play audio))))
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
(:require [reagent.core :as reagent]
|
||||
[re-frame.core :as re-frame]
|
||||
[day8.re-frame.http-fx]
|
||||
[airsonic-ui.audio] ; <- just registers effects
|
||||
[airsonic-ui.routes :as routes]
|
||||
[airsonic-ui.events :as events]
|
||||
[airsonic-ui.views :as views]
|
||||
|
|
|
|||
|
|
@ -62,6 +62,16 @@
|
|||
(println "api call gone bad; CORS headers missing? check for :status 0" event)
|
||||
db))
|
||||
|
||||
;; musique
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::play-song
|
||||
(fn [{:keys [db]} [_ song]]
|
||||
(let [song-url (api/url "stream" (merge {:id (:id song)}
|
||||
(:login db)))]
|
||||
(println "Requesting to stream song at" song-url)
|
||||
{:play-song song-url})))
|
||||
|
||||
;; routing
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@
|
|||
;; single album
|
||||
|
||||
(defn song-item [song]
|
||||
[:div (str (:artist song) " - " (:title song))])
|
||||
[:div (str (:artist song) " - ")
|
||||
[:a
|
||||
{:on-click #(re-frame/dispatch [::events/play-song song])}
|
||||
(:title song)]])
|
||||
|
||||
(defn song-list [songs]
|
||||
[:ul
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue