[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emms-patches] [COMMIT] emms-lastfm: Fix timer issue when playing radio
From: |
Michael Olson |
Subject: |
[Emms-patches] [COMMIT] emms-lastfm: Fix timer issue when playing radio station. |
Date: |
Fri, 8 Aug 2008 09:29:30 -0700 |
* lisp/emms-lastfm.el (emms-lastfm-radio-sentinel): Cancel the timer only
after emms-player-started-hook is called. Make sure existing timer is
canceled before starting new one. Thanks to Thierry Volpiatto for the
initial code.
(emms-lastfm-cancel-timer-after-stop): New barebones function to add to
emms-player-started-hook.
(emms-lastfm): Remove it from emms-player-started-hook.
---
lisp/emms-lastfm.el | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lisp/emms-lastfm.el b/lisp/emms-lastfm.el
index 1f597d7..11804c8 100644
--- a/lisp/emms-lastfm.el
+++ b/lisp/emms-lastfm.el
@@ -291,6 +291,9 @@ the current track, too."
'emms-lastfm-cancel-timer)
(add-hook 'emms-player-paused-hook
'emms-lastfm-pause)
+ ;; Clean up after EMMS radio
+ (remove-hook 'emms-player-started-hook
+ 'emms-lastfm-cancel-timer-after-stop)
(message "EMMS Last.fm plugin activated"))
(remove-hook 'emms-player-started-hook
'emms-lastfm-handshake-if-needed)
@@ -521,19 +524,25 @@ high. (But then streaming a 128KHz mp3 won't be fun
anyway.)"
(const :tag "Disable" nil))
:group 'emms-lastfm)
+(defun emms-lastfm-cancel-timer-after-stop ()
+ (add-hook 'emms-player-stopped-hook
+ 'emms-lastfm-cancel-timer))
+
(defun emms-lastfm-radio-sentinel (&rest args)
(let ((buffer (current-buffer)))
(emms-http-decode-buffer buffer)
(if (string= (emms-key-value "response" buffer) "OK")
(progn
(kill-buffer buffer)
+ (add-hook 'emms-player-started-hook
+ 'emms-lastfm-cancel-timer-after-stop)
(emms-play-url emms-lastfm-radio-stream-url)
(when emms-lastfm-radio-metadata-period
+ (when emms-lastfm-timer
+ (emms-lastfm-cancel-timer))
(setq emms-lastfm-timer
(run-with-timer 0 emms-lastfm-radio-metadata-period
- 'emms-lastfm-radio-request-metadata))
- (add-hook 'emms-player-stopped-hook
- 'emms-lastfm-cancel-timer))
+ 'emms-lastfm-radio-request-metadata)))
(message "EMMS: Playing Last.fm stream"))
(kill-buffer buffer)
(message "EMMS: Bad response from Last.fm"))))
--
debian.1.5.6.1.19.ge6b2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emms-patches] [COMMIT] emms-lastfm: Fix timer issue when playing radio station.,
Michael Olson <=