Well Emacs itself can’t play media files, it can call an external program to play them. I like have some music as the background when programming, so I have this (stealed from the net)
(defun dired-xmms-play-mp3 (&optional arg)
"play mp3 files marked in dired buffer with xmms"
(interactive)
(let ((files nil))
(progn
(mapcar
‘(lambda (x)
(setq files
(concat files " \"" x "\"")))
(dired-map-over-marks
(dired-get-filename) arg))
(start-process-shell-command
"dired-play-mp3" "*dired-play-mp3*" "xmms" files))))
;; Example of how to bind this to M-m when opening dired:
(add-hook ‘dired-mode-hook
(function (lambda ()
(define-key dired-mode-map “\M-m” ‘dired-xmms-play-mp3))))
So I can mark some mp3 file in dired, and call xmms to play it.
However it’s not very convience to play with xmms. For example, if I want to change the volume, I’ll need to move my hand from the keyboard to the mouse.
As the EMMS 2.0 is released, I decide to give it a try.
EMMS could call mpg321, mplayer, ogg321, and musicpd to play the media files, I decide to use musicpd because it uses mimimal CPU.
It turns out to be not very hard compared with those command line players, the only thing need an extra care is to set
(setq emms-player-mpd-server-port "2100")
(setq emms-player-mpd-music-directory "/home/ddliu/entertainment/mp3")
correctly, according to the music player daemon settings.
For the rest, just pick the settings you like from emms-setup.el. For me, I have
(require ‘emms-source-playlist)
(require ‘emms-player-simple)
(require ‘emms-player-mplayer)
(setq emms-player-list ‘(emms-player-mpg321
emms-player-ogg123
emms-player-mplayer))
(require ‘emms-info)
(require ‘emms-info-mp3info)
(require ‘emms-info-ogginfo)
(add-to-list ‘emms-track-initialize-functions ‘emms-info-initialize-track)
(add-to-list ‘emms-info-functions ‘emms-info-mp3info)
(add-to-list ‘emms-info-functions ‘emms-info-ogginfo)
(setq emms-track-description-function ‘emms-info-track-description)
(require ‘emms-playlist-mode)
(setq emms-playlist-buffer-name “*Music*”)
(setq emms-playlist-default-major-mode ‘emms-playlist-mode)
;; (require ‘emms-streams)
(require ‘emms-playlist-sort)
(add-to-list ‘emms-info-functions ‘emms-info-mpd)
(add-to-list ‘emms-player-list ‘emms-player-mpd)
Because I don’t like seeing the lyrics or playing times.
Now everthing is set, I can even play movies via EMMS, though I can also press “X” directly from dired
To make it more convience, I have M-m rebined in dired:
And to change volume,
(define-key emms-playlist-mode-map (kbd "<") ‘emms-player-mpd-volume-down)
Finially, goto the play list buffer easily:
"Switch to the music buffer"
(interactive)
(switch-to-buffer "*Music*"))
(define-key goto-global-map "m" ‘ddliu-goto-music)
Enjoy
Post a Comment
You could use <code type="name"> to get your code colorized