From 52c0408569a0b1de932d52e71fee5fb0163782e2 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Thu, 27 Oct 2022 07:17:04 -0500 Subject: Add: session file --- playlist.lisp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'playlist.lisp') diff --git a/playlist.lisp b/playlist.lisp index 82b796f..0d6e589 100644 --- a/playlist.lisp +++ b/playlist.lisp @@ -46,14 +46,12 @@ (when (plusp pos) (nth (1- pos) (tracks ctl))))) -;;; CLIENT SESSION +;;; SESSION UTIL (defun install-new-playlist-ctl (playlist body) - (setf (connection-data-item body "playlist-ctl") + (setf (cur-playlist-ctl body) (make-instance 'playlist-ctl :playlist playlist))) -(defun get-playlist-ctl (obj) - (connection-data-item obj "playlist-ctl")) ;;; PLAYBACK CONTROL @@ -78,7 +76,7 @@ ;;; CLIENT CONTROL (defun initialize-now-playing (elem) - (when-let (ctl (get-playlist-ctl elem)) + (when-let (ctl (cur-playlist-ctl elem)) (when (tracks ctl) (setf (now-playing-track ctl) (first (tracks ctl))) (load-now-playing-display ctl (now-playing-track ctl))))) @@ -94,7 +92,7 @@ (text (np-time ctl)) (secs-to-hms 0)))) (defun toggle-now-playing (e) - (when-let (ctl (get-playlist-ctl e)) + (when-let (ctl (cur-playlist-ctl e)) (if-let (np (now-playing-track ctl)) (if (pausedp (audio np)) (start-playback ctl) @@ -103,7 +101,7 @@ (defun advance-now-playing (e) (when-let* ((ctl - (get-playlist-ctl e)) + (cur-playlist-ctl e)) (next (find-next-track ctl (now-playing-track ctl)))) (stop-playback ctl) @@ -113,7 +111,7 @@ (defun previous-now-playing (e) (when-let* ((ctl - (get-playlist-ctl e)) + (cur-playlist-ctl e)) (prev (find-previous-track ctl (now-playing-track ctl)))) (stop-playback ctl) @@ -122,7 +120,7 @@ (start-playback ctl))) (defun update-now-playing-time (e) - (when-let* ((ctl (get-playlist-ctl e)) + (when-let* ((ctl (cur-playlist-ctl e)) (tr (now-playing-track ctl))) (setf (text (np-time ctl)) (secs-to-hms @@ -130,7 +128,7 @@ (defun play-this-audio (audio) - (when-let (ctl (get-playlist-ctl audio)) + (when-let (ctl (cur-playlist-ctl audio)) (let ((np (now-playing-track ctl))) (unless (and np (eq audio (audio np))) (let ((tr @@ -142,14 +140,14 @@ (defun remove-track (track-ctl) - (when-let ((ctl (get-playlist-ctl (container track-ctl)))) + (when-let ((ctl (cur-playlist-ctl (container track-ctl)))) (when (delete-track-at (playlist ctl) (position track-ctl (tracks ctl))) (destroy (container track-ctl)) (setf (tracks ctl) (delete track-ctl (tracks ctl)) (text (pl-dur ctl)) (secs-to-hms (playlist-duration (playlist ctl))))))) (defun move-track-down (track-ctl) - (when-let* ((ctl (get-playlist-ctl (container track-ctl))) + (when-let* ((ctl (cur-playlist-ctl (container track-ctl))) (pos (position track-ctl (tracks ctl)))) (when (swap-tracks (playlist ctl) pos (1+ pos)) (let* ((next @@ -161,7 +159,7 @@ (place-before (container track-ctl) (container next)))))) (defun move-track-up (track-ctl) - (when-let* ((ctl (get-playlist-ctl (container track-ctl))) + (when-let* ((ctl (cur-playlist-ctl (container track-ctl))) (pos (position track-ctl (tracks ctl)))) (when (swap-tracks (playlist ctl) pos (1- pos)) (let* ((next @@ -249,14 +247,14 @@ (set-on-click item (alambda (play-this-audio audio))))) (defun create-track-listing (parent pl) - (when-let (ctl (get-playlist-ctl parent)) + (when-let (ctl (cur-playlist-ctl parent)) (let ((ol (create-ordered-list parent))) (setf (pl-tracks ctl) ol) (dolist (track (playlist-tracks pl)) (create-track-list-item ol track ctl))))) (defun append-track-list-item (obj track) - (when-let (ctl (get-playlist-ctl obj)) + (when-let (ctl (cur-playlist-ctl obj)) (create-track-list-item (pl-tracks ctl) track ctl) (setf (text (pl-dur ctl)) (secs-to-hms (playlist-duration (playlist ctl)))))) -- cgit v1.2.3