aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorLucas Bonnet <lucas@rincevent.net>2011-04-25 18:51:28 +0200
committerLucas Bonnet <lucas@rincevent.net>2011-04-25 18:51:28 +0200
commit298e022d7fba7a991fcc9cf25306a7b8eb8a612e (patch)
tree54c7f564bd0267f601489eb3465507b86b3eac7b /lisp
parent2374a3c8868f109543453ef7a269ad2d580b7cdc (diff)
* lisp/emms-browser.el (emms-browser-track-duration): New function to allow custom browser track-formats to display track duration.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emms-browser.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/lisp/emms-browser.el b/lisp/emms-browser.el
index 0d1da3c..6bff443 100644
--- a/lisp/emms-browser.el
+++ b/lisp/emms-browser.el
@@ -795,6 +795,16 @@ This will be in the form '(1998) '."
(concat
"(" year ") "))))
+(defun emms-browser-track-duration (track)
+ "Return a string representation of a track duration.
+If no duration is available, return an empty string."
+ (let ((pmin (emms-track-get track 'info-playing-time-min))
+ (psec (emms-track-get track 'info-playing-time-sec))
+ (ptot (emms-track-get track 'info-playing-time)))
+ (cond ((and pmin psec) (format "%02d:%02d" pmin psec))
+ (ptot (format "%02d:%02d" (/ ptot 60) (% ptot 60)))
+ (t ""))))
+
(defun emms-browser-make-bdata (data name type level)
"Return a browser data item from ALIST.
DATA should be a list of DB items, or a list of tracks.
@@ -1691,6 +1701,7 @@ If > album level, most of the track data will not make sense."
("p" . ,(emms-track-get track 'info-performer))
("t" . ,(emms-track-get track 'info-title))
("T" . ,(emms-browser-track-number track))
+ ("d" . ,(emms-browser-track-duration track))
("cS" . ,(emms-browser-get-cover-str path 'small))
("cM" . ,(emms-browser-get-cover-str path 'medium))
("cL" . ,(emms-browser-get-cover-str path 'large))))