aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-10-31 14:42:28 -0500
committerColin Okay <colin@cicadas.surf>2022-10-31 14:42:28 -0500
commit31c57b91c0bd3174f86cd05e19d9a4c32c26bb41 (patch)
treeee91f2b095c6bff1bc71b2a62a7fd62993ec0cf4
parent15c252ce52bc94ef4cb41550780ae1a52e9d3221 (diff)
Add: now-playing-track css class; controller-alive-p
-rw-r--r--playlist.lisp13
1 files changed, 10 insertions, 3 deletions
diff --git a/playlist.lisp b/playlist.lisp
index 236da00..f1afb42 100644
--- a/playlist.lisp
+++ b/playlist.lisp
@@ -54,7 +54,8 @@
"Stored in the clog connection object")
(defun cur-playlist-ctl (obj)
- (connection-data-item obj +playlist-connection-key+))
+ (when (connection-data obj)
+ (connection-data-item obj +playlist-connection-key+)))
(defun (setf cur-playlist-ctl) (newval obj)
(setf (connection-data-item obj +playlist-connection-key+) newval))
@@ -77,7 +78,7 @@
(let ((viewers
(playlist-viewers ctl)))
(setf (gethash (playlist ctl) *playlist-viewers*)
- (pushnew ctl viewers))))
+ (cons ctl (remove-if-not 'controller-alive-p viewers)))))
(defun remove-playlist-viewer (ctl)
(let ((viewers
@@ -85,14 +86,19 @@
(setf (gethash (playlist ctl) *playlist-viewers*)
(delete ctl viewers))))
+(defun controller-alive-p (ctl)
+ (connection-data (pl-title ctl)))
+
(defmacro for-playlist-viewers (clog-elem ctlvar &body body)
`(dolist (,ctlvar (playlist-viewers (cur-playlist-ctl ,clog-elem)))
- ,@body))
+ (if (controller-alive-p ctl)
+ (progn ,@body))))
;;; PLAYBACK CONTROL
(defun start-playback (ctl)
(when-let (tr (now-playing-track ctl))
+ (add-class (first-child (container tr)) "now-playing-track")
(play-media (audio tr))
(setf (text (np-play ctl)) "⏸")))
@@ -104,6 +110,7 @@
(defun stop-playback (ctl)
(when-let (tr (now-playing-track ctl))
(pause-media (audio tr))
+ (remove-class (first-child (container tr)) "now-playing-track")
(setf (media-position (audio tr)) 0
(now-playing-track ctl) nil
(text (np-play ctl)) "⏵")))