From 19524caf26e674c7d24180edf5b2d45515148f1a Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 27 Nov 2012 11:12:33 +0100 Subject: .emacs.d/site-lisp/metalexpress.el --- .emacs.d/site-lisp/metalexpress.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to '.emacs.d/site-lisp/metalexpress.el') diff --git a/.emacs.d/site-lisp/metalexpress.el b/.emacs.d/site-lisp/metalexpress.el index 9d57c19..ef67d83 100644 --- a/.emacs.d/site-lisp/metalexpress.el +++ b/.emacs.d/site-lisp/metalexpress.el @@ -32,13 +32,18 @@ "http://usa7-vn.mixstream.net/listen/8248.m3u" "The URL of the Metal Express Radio stream.") +(defun mer-proc-filter (proc string) + (when (string-match "^ICY Info: StreamTitle='\\(.*\\)';StreamUrl='';" + string) + (message (match-string 1 string)))) + ;;;###autoload (defun metal-express-radio-start () "Start listening to Metal Express Radio." (interactive) - (async-shell-command - (concat "mplayer " metal-express-radio-playlist-url) - "*Metal Express Radio*")) + (let ((proc (start-process "metalexpress" "*Metal Express Radio*" + "mplayer" metal-express-radio-playlist-url))) + (set-process-filter proc #'mer-proc-filter))) (defun metal-express-radio-stop () "Stop listening to Metal Express Radio." -- cgit v1.2.3-54-g00ecf From 272c8f72380cf7c5355df5735d951cc97ecb9ffc Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 4 Dec 2012 17:44:57 +0100 Subject: .emacs.d/site-lisp/metalexpress.el --- .emacs.d/site-lisp/metalexpress.el | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to '.emacs.d/site-lisp/metalexpress.el') diff --git a/.emacs.d/site-lisp/metalexpress.el b/.emacs.d/site-lisp/metalexpress.el index ef67d83..2f77638 100644 --- a/.emacs.d/site-lisp/metalexpress.el +++ b/.emacs.d/site-lisp/metalexpress.el @@ -30,12 +30,32 @@ (defcustom metal-express-radio-playlist-url "http://usa7-vn.mixstream.net/listen/8248.m3u" - "The URL of the Metal Express Radio stream.") + "The URL of the Metal Express Radio stream." + :group 'metal-express-radio + :type 'string) + +(defcustom metal-express-radio-song-changed-hook nil + "Hook run when the currently playing song changes." + :type 'hook + :group 'metal-express-radio) + +(defvar metal-express-radio-currently-playing nil + "The currently playing song.") (defun mer-proc-filter (proc string) (when (string-match "^ICY Info: StreamTitle='\\(.*\\)';StreamUrl='';" string) - (message (match-string 1 string)))) + (setq metal-express-radio-currently-playing (match-string 1 string)) + (apply 'run-hooks metal-express-radio-song-changed-hook))) + +(defun metal-express-radio-echo-currently-playing () + (interactive) + (message metal-express-radio-currently-playing)) + +(defun metal-express-radio-notify () + (interactive) + (notifications-notify :title "Now playing:" + :body metal-express-radio-currently-playing)) ;;;###autoload (defun metal-express-radio-start () @@ -50,5 +70,10 @@ (interactive) (kill-process (get-buffer-process "*Metal Express Radio*"))) +(add-hook 'metal-express-radio-song-changed-hook + 'metal-express-radio-echo-currently-playing) +(add-hook 'metal-express-radio-song-changed-hook + 'metal-express-radio-notify) + (provide 'metalexpress) ;;; metalexpress.el ends here -- cgit v1.2.3-54-g00ecf