aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--emms-lastfm.el25
-rw-r--r--emms-player-mpd.el59
3 files changed, 53 insertions, 33 deletions
diff --git a/NEWS b/NEWS
index bb96cd6..bfb723f 100644
--- a/NEWS
+++ b/NEWS
@@ -33,6 +33,8 @@ News since version 2.1:
- Display the correct error message if an error occurs while
trying to play a stream.
- Handle any encoding errors that occur during playback.
+ - Integrate with emms-lastfm.el in `emms-player-mpd-show', if
+ emms-lastfm is loaded and active.
- emms-playing-time supports different display styles now.
- emms-lyrics: Now support lyrics auto-scrolling.
diff --git a/emms-lastfm.el b/emms-lastfm.el
index ced9a0b..ffb1e20 100644
--- a/emms-lastfm.el
+++ b/emms-lastfm.el
@@ -435,11 +435,18 @@ high. (But then streaming a 128KHz mp3 won't be fun anyway.)"
(message "EMMS: Playing Last.fm stream"))
(message "EMMS: Bad response from Last.fm"))))
-(defun emms-lastfm-np (&optional arg)
- "Show the currently-playing lastfm radio tune."
+(defun emms-lastfm-np (&optional insertp callback)
+ "Show the currently-playing lastfm radio tune.
+
+If INSERTP is non-nil, insert the description into the current
+buffer instead.
+
+If CALLBACK is a function, call it with the current buffer and
+description as arguments instead of displaying the description or
+inserting it."
(interactive "P")
(emms-lastfm-radio-request-metadata
- (lambda (status arg buffer)
+ (lambda (status insertp buffer callback)
(let (artist title)
(save-excursion
(set-buffer emms-lastfm-buffer)
@@ -449,11 +456,13 @@ high. (But then streaming a 128KHz mp3 won't be fun anyway.)"
(let ((msg (if title (format emms-show-format
(format "%s - %s" artist title))
"Nothing playing right now")))
- (if (and arg title)
- (with-current-buffer buffer
- (insert msg))
- (message msg)))))
- (list arg (current-buffer))))
+ (cond ((functionp callback)
+ (funcall callback buffer msg))
+ ((and insertp title)
+ (with-current-buffer buffer
+ (insert msg)))
+ (t (message msg))))))
+ (list insertp (current-buffer) callback)))
(defun emms-lastfm-radio-similar-artists (artist)
"Plays the similar artist radio of ARTIST."
diff --git a/emms-player-mpd.el b/emms-player-mpd.el
index f329f0c..b5fb198 100644
--- a/emms-player-mpd.el
+++ b/emms-player-mpd.el
@@ -1002,30 +1002,38 @@ positive or negative."
(when info
(when name
(setq desc name))
- (when file
- (let ((track (emms-dictionary '*track*))
- track-desc)
- (if (string-match "\\`http://" file)
- (emms-track-set track 'type 'url)
- (emms-track-set track 'type 'file))
- (emms-track-set track 'name file)
- (emms-info-mpd track info)
- (setq track-desc (emms-track-description track))
- (when (and (stringp track-desc) (not (string= track-desc "")))
- (setq desc (if desc
- (concat desc ": " track-desc)
- track-desc))))))
- (if (not desc)
- (message "Nothing playing right now")
- (setq desc (format emms-show-format desc))
- (cond ((functionp callback)
- (funcall callback buffer desc))
- (insertp
- (when (buffer-live-p buffer)
- (with-current-buffer buffer
- (insert desc))))
- (t
- (message "%s" desc))))))
+ ;; if we are playing lastfm radio, use its show function instead
+ (if (and (boundp 'emms-lastfm-radio-stream-url)
+ (stringp emms-lastfm-radio-stream-url)
+ (string= emms-lastfm-radio-stream-url file))
+ (with-current-buffer buffer
+ (and (fboundp 'emms-lastfm-np)
+ (emms-lastfm-np insertp callback)))
+ ;; otherwise build and show the description
+ (when file
+ (let ((track (emms-dictionary '*track*))
+ track-desc)
+ (if (string-match "\\`http://" file)
+ (emms-track-set track 'type 'url)
+ (emms-track-set track 'type 'file))
+ (emms-track-set track 'name file)
+ (emms-info-mpd track info)
+ (setq track-desc (emms-track-description track))
+ (when (and (stringp track-desc) (not (string= track-desc "")))
+ (setq desc (if desc
+ (concat desc ": " track-desc)
+ track-desc))))))
+ (if (not desc)
+ (message "Nothing playing right now")
+ (setq desc (format emms-show-format desc))
+ (cond ((functionp callback)
+ (funcall callback buffer desc))
+ (insertp
+ (when (buffer-live-p buffer)
+ (with-current-buffer buffer
+ (insert desc))))
+ (t
+ (message "%s" desc)))))))
;;;###autoload
(defun emms-player-mpd-show (&optional insertp callback)
@@ -1035,7 +1043,8 @@ If INSERTP is non-nil, insert the description into the current
buffer instead.
If CALLBACK is a function, call it with the current buffer and
-description.
+description as arguments instead of displaying the description or
+inserting it.
This function uses `emms-show-format' to format the current track.
It differs from `emms-show' in that it asks MusicPD for the current track,