diff options
-rw-r--r-- | vampire.lisp | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/vampire.lisp b/vampire.lisp index 9001643..cfac3b9 100644 --- a/vampire.lisp +++ b/vampire.lisp @@ -178,12 +178,33 @@ (when-let (track (now-playing ctl)) (play-media track))) +(defun load-track-display (ctl) + (with-slots (now-playing track-display) ctl + (when now-playing + (let ((track (get-audio-track ctl now-playing))) + (setf (inner-html track-display) "") + (with-clog-create track-display + (div () + (section (:h3 :content "Now Playing")) + (img (:url-src (track-thumb-url track) :bind thumb)) + (section (:h4 :content (track-title track)))) + (setf (width thumb) 100)))))) + +(defun initialize-playlist/ctl (body) + (when-let (ctl (playlist/ctl body)) + (setf now-playing (car (first (audio->track ctl)))) + (load-track-display ctl))) + (defun playlist/ctl (obj) (connection-data-item obj "playlist/ctl")) -(defun install-playlist/ctl (playlist display) - (setf (connection-data-item display "playlist/ctl") - (make-instance 'playlist/ctl :playlist playlist :track-display display))) +(defun install-playlist/ctl (playlist obj) + (setf (connection-data-item obj "playlist/ctl") + (make-instance 'playlist/ctl :playlist playlist))) + +(defun install-track-display (display) + (let ((ctl (playlist/ctl display))) + (setf (track-display ctl) display))) (defun install-audio-track (audio track &optional (position -1)) (when-let (ctl (playlist/ctl audio)) @@ -202,7 +223,8 @@ (when-let (ctl (playlist/ctl audio)) (stop-playback ctl) (setf (now-playing ctl) audio) - (start-playback ctl))) + (start-playback ctl) + (load-track-display ctl))) (defun ctl/next-track (audio) (when-let (ctl (playlist/ctl audio)) @@ -211,7 +233,8 @@ (stop-playback ctl) (when next (setf (now-playing ctl) (car next)) - (start-playback ctl))))) + (start-playback ctl) + (load-track-display ctl))))) ;;; @@ -282,9 +305,12 @@ (with-clog-create body (div () (section (:h2 :content (playlist-title playlist))) + (div (:bind track-display)) (div () (track-listing (playlist))) - (track-form (playlist)))))) + (track-form (playlist))) + (install-track-display track-display) + (initialize-playlist/ctl body)))) (defun user-page (body) (if-let (user (session-user body)) |