diff options
Diffstat (limited to 'playlist.lisp')
-rw-r--r-- | playlist.lisp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/playlist.lisp b/playlist.lisp index 3579c83..cd9533e 100644 --- a/playlist.lisp +++ b/playlist.lisp @@ -45,6 +45,13 @@ (with-transaction () (add-track tr pl))) +(defun delete-track-at (pl pos) + (when-let (tr (nth pos (playlist-tracks pl))) + (with-transaction () + (setf (playlist-tracks pl) + (delete tr (playlist-tracks pl))) + t))) + (defun new-track (file trackinfo) "Trackinfo is a plist containing information about the track to create." (with-transaction () @@ -187,6 +194,13 @@ (load-now-playing-display ctl tr)))))) +(defun remove-track (track-ctl) + (when-let ((ctl (get-playlist-ctl (container track-ctl)))) + (when (delete-track-at (playlist ctl) (position track-ctl (tracks ctl))) + (setf (tracks ctl) + (delete track-ctl (tracks ctl))) + (destroy (container track-ctl))))) + ;;; CLIENT UI (defun playlist-title-content (playlist) @@ -237,18 +251,20 @@ (with-clog-create list (list-item (:bind container) (p () + (span (:content "[X] " :hidden t :bind delbtn)) (span (:content (track-listing-line track))) (span (:content " -- ")) (span (:content (secs-to-hms (or (track-duration track) 0))))) (audio (:source (media-url-path track) :controls nil :bind audio))) - (setf (tracks ctl) - (insert-nth - (make-instance 'track-ctl - :container container - :audio audio - :track track) - -1 - (tracks ctl))) + (let ((track-ctl + (make-instance 'track-ctl + :container container + :audio audio + :track track))) + (setf (tracks ctl) + (insert-nth track-ctl -1 (tracks ctl) t)) + (setf (visiblep delbtn) t) + (set-on-click delbtn (alambda (remove-track track-ctl)))) (set-on-time-update audio 'update-now-playing-time) (set-on-ended audio 'advance-now-playing) (set-on-click container (alambda (play-this-audio audio))))) |