From f128ac46140f1aa171a2f6f703693485e6a451c4 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Mon, 20 Mar 2006 07:13:00 +0000 Subject: emms-player-mpd: Make pausing work after importing a playlist from MusicPD. darcs-hash:20060320071337-1bfb2-7bba470fcb6076795954f2a73bb86b985ffd46e4.gz --- emms-player-mpd.el | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'emms-player-mpd.el') diff --git a/emms-player-mpd.el b/emms-player-mpd.el index 684cace..d52a2a7 100644 --- a/emms-player-mpd.el +++ b/emms-player-mpd.el @@ -434,20 +434,24 @@ MusicPD playlist." (mapc #'emms-playlist-insert-track (emms-player-mpd-get-tracks))) (setq emms-player-mpd-playlist-id (emms-player-mpd-get-playlist-id))) -(defun emms-player-mpd-detect-song-change () +(defun emms-player-mpd-detect-song-change (&optional info) "Detect whether a song change has occurred. -This is usually called by a timer." - (let* ((info (emms-player-mpd-get-status)) - (song (emms-player-mpd-get-current-song info)) - (status (emms-player-mpd-get-state info)) - (time (emms-player-mpd-get-playing-time info))) +This is usually called by a timer. + +If INFO is specified, use that instead of acquiring the necessary +info from MusicPD." + (unless info + (setq info (emms-player-mpd-get-status))) + (let ((song (emms-player-mpd-get-current-song info)) + (status (emms-player-mpd-get-state info)) + (time (emms-player-mpd-get-playing-time info))) (cond ((string= status "stop") (emms-cancel-timer emms-player-mpd-status-timer) (setq emms-player-mpd-status-timer nil) (setq emms-player-stopped-p t) (emms-player-stopped)) ((string= status "pause") - nil) + (setq emms-player-paused-p t)) ((string= status "play") (unless (or (null song) (and emms-player-mpd-current-song @@ -565,7 +569,10 @@ Afterward, the status of MusicPD will be tracked." (when emms-player-mpd-status-timer (emms-cancel-timer emms-player-mpd-status-timer)) (setq emms-player-mpd-current-song nil) - (emms-player-mpd-detect-song-change) + (let ((info (emms-player-mpd-get-status))) + (unless (string= (emms-player-mpd-get-state info) "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))) -- cgit v1.2.3