diff options
author | Colin Okay <colin@cicadas.surf> | 2022-10-26 14:14:30 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-10-26 14:14:30 -0500 |
commit | b500349671a80de641a18b9a28125071e7dfa6e7 (patch) | |
tree | 135d9bb671d23d3366f28b03d38c42d8a8ae2cf9 /playlist.lisp | |
parent | b1b3fcf39cdf7bae870d2dbc8eea172ac806f6b2 (diff) |
Fix+Add: eval-when of defclass/bknr; track upload form;
Diffstat (limited to 'playlist.lisp')
-rw-r--r-- | playlist.lisp | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/playlist.lisp b/playlist.lisp index 303dbec..503c69a 100644 --- a/playlist.lisp +++ b/playlist.lisp @@ -239,12 +239,13 @@ (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))) + (insert-nth + (make-instance 'track-ctl + :container container + :audio audio + :track track) + -1 + (tracks 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))))) @@ -255,9 +256,40 @@ (dolist (track (playlist-tracks pl)) (create-track-list-item ol track ctl)))) -(defun create-new-track-form (parent pl ctl) - ) +(defun append-track-list-item (obj track) + (when-let (ctl (get-playlist-ctl obj)) + (create-track-list-item (pl-tracks ctl) track ctl))) +(defun create-new-track-form (parent pl) + (with-clog-create parent + (div () + (section (:h3 :content "Add A Track")) + (label (:content "Paste a URL: " :bind url-label)) + (form-element (:text :bind url-input)) + (button (:content "Fetch Track" :bind button)) + (div (:bind notice-area))) + (label-for url-label url-input) + (setf (place-holder url-input) "https://www.youtube.com/watch?v=dQw4w9WgXcQ") + (set-on-click + button + (alambda + (let* ((url + (value url-input)) + (notice + (create-p notice-area :content (format nil "... Fetching ~a" url)))) + (setf (value url-input) "") + (add-fetch-track-job + url + (lambda (track) + (destroy notice) + (append-track pl track) + (append-track-list-item parent track)) + (lambda (err) + (destroy notice) + (format t "~a" err) + (alert (window (connection-body parent)) + (format nil "Error while fetching track at: ~a~%" + url))))))))) (defun playlist-key-from-url (url) (first (last (ppcre:split "/" (nth 4 (multiple-value-list (quri:parse-uri url))))))) @@ -274,7 +306,6 @@ (section (:h2 :content (playlist-title-content pl) :bind title-elem)) (now-playing-display (ctl)) (track-listing (pl ctl :bind tracks-elem)) - ;(new-track-form (pl ctl)) - ) + (new-track-form (pl))) (setf (pl-title ctl) title-elem (pl-tracks ctl) tracks-elem))))) |