EMMS: Add emms-tracks-duraction to display the duration of all tracks in region.

master
Pierre Neidhardt 2019-09-05 17:27:15 +02:00
parent 2a6cdd04a4
commit 98388b0fe7
1 changed files with 23 additions and 0 deletions

View File

@ -143,4 +143,27 @@ character."
": " (emms-track-name track))))))
(setq emms-track-description-function 'ambrevar/emms-track-description-with-album)
(defun ambrevar/emms-tracks-duration (begin end)
"Display play time of tracks in region."
(interactive "r")
(if (not (use-region-p))
(message "%s" (emms-browser-track-duration
(car (emms-browser-tracks-at-point))))
(let* ((total-time)
(first-line (line-number-at-pos begin))
(last-line (line-number-at-pos end))
(count 0))
(setq total-time
(save-mark-and-excursion
(cl-loop for line from first-line to last-line
do (goto-line line)
for time = (emms-track-get (car (emms-browser-tracks-at-point))
'info-playing-time)
when time
do (cl-incf count)
when time
sum time)))
(message "%02d:%02d for %d tracks" (/ total-time 60) (% total-time 60)
count))))
(provide 'init-emms)