diff options
author | Michael Olson <mwolson@gnu.org> | 2007-04-08 20:50:00 +0000 |
---|---|---|
committer | Michael Olson <mwolson@gnu.org> | 2007-04-08 20:50:00 +0000 |
commit | 7c05231415f877a3902f4f247b512c5373a08407 (patch) | |
tree | d7f70a62406c1ffc8aa3c55515013b29535e41eb /emms-player-mpd.el | |
parent | 2bb38ee60a4f6de5ca6ac74a007bd27ec59f8c07 (diff) |
emms-player-mpd: Integrate with emms-lastfm to show track
* emms-lastfm (emms-lastfm-np): Expand to take optional callback
argument. Rename `arg' to `insertp' for clarity.
* emms-player-mpd (emms-player-mpd-show-1): Detect if emms-lastfm is
activated, and if the current track is a LastFM URL. If so, call
emms-lastfm-np rather than continuing on.
(emms-player-mpd-show): Docfix.
darcs-hash:20070408205000-1bfb2-6207ca703571a4602c7b1510f62be33df9722a8d.gz
Diffstat (limited to 'emms-player-mpd.el')
-rw-r--r-- | emms-player-mpd.el | 59 |
1 files changed, 34 insertions, 25 deletions
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, |