Well I said I could use music play daemon to play media files within Emacs, there’s something made it uncomfortable: every time I found some new mp3 files, I’ll need to rebuild the mpd database and restart the daemon. This is boring especially when I get one from a friend and just want to play it once: The mpd backend always comes before mplayer and all other backends and report “this file is not in the database” and I have to switch to the command line :( class=
wp-smiley />
And today I find the “-slave” option of mplayer. This makes mplayer a daemon running at the background and waiting for commands from Emacs. So there’s no need to tweak later-do-interval and I can change volume via mplayer.
So here’s my new setting, using mplayer instead of mpd:
emms-player-mplayer-parameters ‘("-slave")
emms-player-mpg321-command-name "mpg123"
emms-player-list
‘(emms-player-mplayer
emms-player-mplayer-playlist
emms-player-mpg321
emms-player-ogg123))
(defun ddliu-emms-player-mplayer-volume-up ()
"Depends on mplayer’s -slave mode."
(interactive)
(process-send-string
emms-player-simple-process-name "volume 1\n"))
(defun ddliu-emms-player-mplayer-volume-down ()
“Depends on mplayer’s -slave mode.”
(interactive)
(process-send-string
emms-player-simple-process-name “volume -1\n”))
(define-key emms-playlist-mode-map (kbd “>”) ‘ddliu-emms-player-mplayer-volume-up)
(define-key emms-playlist-mode-map (kbd “<”) ‘ddliu-emms-player-mplayer-volume-down)
One drawback is that if I exit Emacs, the music will stop. But… who will exim Emacs?



Verbatim Copying Permitted
Comments 1
thanks.
And I modified it a little bit so that it work with emms-volume-raise/emms-volume-lower
(defun my-mplayer-volume-change-function (amount)
Posted 03 Jan 2009 at 3:23 pm ¶(interactive)
(process-send-string
emms-player-simple-process-name (format “volume %d\n” amount)))
(setq emms-volume-change-function ‘my-mplayer-volume-change-function)
Post a Comment
You could use <code type="name"> to get your code colorized
Your email is never published nor shared. Required fields are marked *