New convenience function for displaying "Now Playing".
authorSteve Youngs <steve@sxemacs.org>
Mon, 19 Aug 2013 07:30:51 +0000 (17:30 +1000)
committerSteve Youngs <steve@sxemacs.org>
Mon, 19 Aug 2013 07:30:51 +0000 (17:30 +1000)
* mpd.el (mpd-now-playing): New.

Signed-off-by: Steve Youngs <steve@sxemacs.org>
mpd.el

diff --git a/mpd.el b/mpd.el
index f703466..b695f56 100644 (file)
--- a/mpd.el
+++ b/mpd.el
@@ -619,6 +619,24 @@ Year: %s  Genre: %s\n
     (focus-frame cframe)
     (mpd-update-variables)))
 
+(defun mpd-now-playing ()
+  "Return a formatted string of Title and Artist.
+
+This is for use in things like Gnus for a X-Now-Playing header etc."
+  (with-fboundp 'taglib:show-tag
+    (let ((title (and mpd-current-filename
+                     (taglib:show-tag
+                      (expand-file-name
+                       (mpd-file) mpd-music-directory)
+                      'title)))
+         (artist (and mpd-current-filename
+                      (taglib:show-tag
+                       (expand-file-name
+                        (mpd-file) mpd-music-directory)
+                       'artist))))
+      (format "%s --- [%s]"
+             (or title "The Sounds of Silence")
+             (or artist "Marcel Marceau")))))
 
 (provide 'mpd)