summaryrefslogtreecommitdiff
path: root/playlist.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'playlist.lisp')
-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)) "⏵")))