[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emms-help] Now-playing message
From: |
Michael Olson |
Subject: |
[emms-help] Now-playing message |
Date: |
Sun, 08 Apr 2007 19:10:58 -0400 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.96 (gnu/linux) |
I came up with this today, while putting off more-important and
more-boring work. Let me know what you think.
The idea is to message the description of the currently-playing track
when it changes, checking every `np-interval' (default: 3) seconds.
This is especially useful for Internet radio feeds.
If you're using something other than MusicPD, you'll have to modify
`np-maybe'. I wasn't sure if any backends were capable of getting the
currently-playing song for radio feeds besides emms-player-mpd and
emms-lastfm, so I didn't bother making this more general.
;;; Every time the song changes, show me its description
(defvar np-interval 3
"How often (in seconds) to check whether the current song has changed.")
;; Internal
(defvar np-last nil
"Description for most recently-played track.")
(defvar np-timer nil
"Timer used by `np-maybe'.")
(defun np-maybe ()
(emms-player-mpd-show
nil
(lambda (buffer desc)
(when (stringp desc)
(unless (and (stringp np-last)
(string= np-last desc))
(setq np-last desc)
(message desc))))))
(defun np-insinuate ()
(unless np-timer
(setq np-timer (run-at-time t np-interval #'np-maybe))))
(defun np-remove ()
(when np-timer
(emms-cancel-timer np-timer)
(setq np-timer nil)))
(add-hook 'emms-player-started-hook #'np-insinuate)
(add-hook 'emms-player-stopped-hook #'np-remove)
(add-hook 'emms-player-finished-hook #'np-remove)
--
Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/
Interests: Lisp, text markup, protocols -- Jabber: mwolson_at_hcoop.net
/` |\ | | | Projects: Emacs, Muse, ERC, EMMS, Planner, ErBot, DVC
|_] | \| |_| Reclaim your digital rights by eliminating DRM.
See http://www.defectivebydesign.org/what_is_drm for details.
pgpHMYd6Ub9e0.pgp
Description: PGP signature
- [emms-help] Now-playing message,
Michael Olson <=