diff options
| author | Michael Olson <mwolson@gnu.org> | 2008-08-08 09:29:30 -0700 | 
|---|---|---|
| committer | Michael Olson <mwolson@gnu.org> | 2008-08-08 09:29:30 -0700 | 
| commit | c6a98ba99332e8398f58afad0116e0018882514b (patch) | |
| tree | 9357cb38d814b26bdfff665b06b4b7d260e4cc79 /lisp | |
| parent | cf588f5ea96b7523965ac48bc39e6d9d2dc4e828 (diff) | |
emms-lastfm: Fix timer issue when playing radio station.
* 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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | 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"))))  | 
