Monday, June 21, 2010

Sample emms .emacs configuration

You should install mp3info linux package with emms, if you want to see the song title instead of filename with the full path. For Ubuntu it is;
sudo apt-get install emms mp3info

Below configuration prints the song title if exists, else it removes the path info and displays only filename on the mod-line. And also it defines some global keys and auto loads a playlist.

(display-time)
(require 'emms)
(require 'emms-setup)
(emms-default-players)
(emms-standard)
(emms-all)
(require 'emms-player-simple)
(require 'emms-source-file)
(require 'emms-source-playlist)
(setq emms-info-asynchronously nil)
(setq emms-player-list '(emms-player-mpg321
emms-player-ogg123
emms-player-mplayer))

;;(require 'emms-mode-line)
;;(emms-mode-line 1)
(require 'emms-playing-time)
(emms-playing-time 1)

(setq emms-mode-line-mode-line-function
(lambda nil
(let ((track (emms-playlist-current-selected-track)))
(let ((title (emms-track-get track 'info-title)))
(let ((name (emms-track-get track 'name)))
(if (not (null title))
(format emms-mode-line-format title)
(if (not (null (string-match "^url: " (emms-track-simple-description track))))
(format emms-mode-line-format "Internet Radio")
(setq name2 (replace-regexp-in-string ".*\/" "" name))
(format emms-mode-line-format name2))))))))
(emms-mode-line-disable)
(emms-mode-line-enable)
(load "emms")
(global-set-key (kbd "C-c p") 'emms-pause)
(global-set-key (kbd "C-c u") 'emms-volume-raise)
(global-set-key (kbd "C-c d") 'emms-volume-lower)
(global-set-key (kbd "C-c f") 'emms-show)
(global-set-key (kbd "C-c n") 'emms-next)
(global-set-key (kbd "C-c P") 'emms-previous)
(global-set-key (kbd "C-c r") 'emms-random)
(global-set-key (kbd "C-c s") 'emms-stop)
(autoload 'emms "/home/barol/mp3/sample.mp3" t) ;;must be valid path
(emms-add-playlist "/home/barol/sample.playlist")
(emms-shuffle)