aboutsummaryrefslogtreecommitdiff
path: root/emms-player-mpd.el
diff options
context:
space:
mode:
authorMichael Olson <mwolson@gnu.org>2006-03-23 13:51:00 +0000
committerMichael Olson <mwolson@gnu.org>2006-03-23 13:51:00 +0000
commitbc984744c80745e666d9ef76b7076eb673a2e67c (patch)
tree57bfb71ab825dc0839a750a21f13d385ee3b1fcd /emms-player-mpd.el
parentf128ac46140f1aa171a2f6f703693485e6a451c4 (diff)
emms-player-mpd: Make importing of MusicPD playlist a bit less error-prone.
darcs-hash:20060323135109-1bfb2-bf5417002b601172af920c21a90a1a26e6e79cb9.gz
Diffstat (limited to 'emms-player-mpd.el')
-rw-r--r--emms-player-mpd.el35
1 files changed, 24 insertions, 11 deletions
diff --git a/emms-player-mpd.el b/emms-player-mpd.el
index d52a2a7..d0431a0 100644
--- a/emms-player-mpd.el
+++ b/emms-player-mpd.el
@@ -431,8 +431,16 @@ current EMMS playlist."
MusicPD playlist."
(with-current-emms-playlist
(emms-playlist-clear)
- (mapc #'emms-playlist-insert-track (emms-player-mpd-get-tracks)))
- (setq emms-player-mpd-playlist-id (emms-player-mpd-get-playlist-id)))
+ (mapc #'emms-playlist-insert-track (emms-player-mpd-get-tracks))
+ (let* ((info (emms-player-mpd-get-status))
+ (id (emms-player-mpd-get-playlist-id info))
+ (song (emms-player-mpd-get-current-song info)))
+ (setq emms-player-mpd-playlist-id id)
+ (if song
+ (progn
+ (goto-line (1+ (string-to-number song)))
+ (emms-playlist-select (point)))
+ (goto-char (point-min))))))
(defun emms-player-mpd-detect-song-change (&optional info)
"Detect whether a song change has occurred.
@@ -451,7 +459,7 @@ info from MusicPD."
(setq emms-player-stopped-p t)
(emms-player-stopped))
((string= status "pause")
- (setq emms-player-paused-p t))
+ nil)
((string= status "play")
(unless (or (null song)
(and emms-player-mpd-current-song
@@ -565,17 +573,22 @@ playlist, and then plays the current track."
"Connect to MusicPD and retrieve its current playlist.
Afterward, the status of MusicPD will be tracked."
(interactive)
- (emms-player-mpd-sync-from-mpd)
(when emms-player-mpd-status-timer
- (emms-cancel-timer emms-player-mpd-status-timer))
+ (emms-cancel-timer emms-player-mpd-status-timer)
+ (setq emms-player-mpd-status-timer nil))
+ (emms-player-mpd-sync-from-mpd)
(setq emms-player-mpd-current-song nil)
- (let ((info (emms-player-mpd-get-status)))
- (unless (string= (emms-player-mpd-get-state info) "stop")
+ (let* ((info (emms-player-mpd-get-status))
+ (state (emms-player-mpd-get-state info)))
+ (unless (string= state "stop")
(setq emms-player-playing-p 'emms-player-mpd))
- (emms-player-mpd-detect-song-change info))
- (setq emms-player-mpd-status-timer
- (run-at-time t emms-player-mpd-check-interval
- 'emms-player-mpd-detect-song-change)))
+ (when (string= state "pause")
+ (setq emms-player-paused-p t))
+ (unless (string= state "stop")
+ (emms-player-mpd-detect-song-change info)
+ (setq emms-player-mpd-status-timer
+ (run-at-time t emms-player-mpd-check-interval
+ 'emms-player-mpd-detect-song-change)))))
(defun emms-player-mpd-start (track)
"Starts a process playing TRACK."