MadanRevoor.com | Aesthetic Web design using Wordpress and JQuery | { This site sponsored by Gatwick Airport Parking }
I have always felt it was cool to play music while working on my files. If you are someone like me, I guess you would enjoy this post. I was simply awed when I was introduced to this feature of Emacs for the first time and blown away by the fact that it allows you to play music while working on your files without having to open one of those GUI based players! Imagine it. I felt determined to make it work on my laptop running openSUSE. In this post, we will look at how Emacs can be customized for playing your favorite music without having to switch windows or losing your focus from work!
STEP 1: All you need for Emacs to play music is to download the emms (Emacs Multimedia System) package for Emacs. You can download it from http://www.gnu.org/software/emms/download/emms-3.0.tar.gz
STEP2: Uncompress or extract the archive using the command ‘tar -xvzf emms-3.0.tar.gz’ or you can do it in two steps using ‘gunzip emms-3.0.tar.gz’ and ‘tar -xvf emms-3.0.tar’. After either case, you shall be left with a folder ‘emms-3.0′.
STEP 3: copy the ‘.el’ files to a convenient location like ‘~/elisp/emms’, if you prefer. Or else, you can leave your ‘emms-3.0′ folder under the downloads directory itself if you don’t mind to bother yourself with a bit of organizing data.
STEP 4: We need to add a line to the ‘~/.emacs’ config file to enable it to find the Emms package. Add the following line to it.
(add-to-list ‘load-path “~/elisp/emms/”)
STEP 5: The following lines to be added to the emacs config file to setup emms.
(require ‘emms-setup)
(emms-standard)
(emms-default-players)
STEP 6: The following lines are optional and if added to the config file shall show the currently playing track as a message (like this “Now Playing: /media/music/song/fav.mp3″) in the mini buffer at the bottom of the Emacs editor.
;; Show the current track each time EMMS
;; starts to play a track with “NP : ”
(add-hook ‘emms-player-started-hook ‘emms-show)
(setq emms-show-format “Now Playing : %s”)
STEP 7: This is also an optional step. You can omit it if you do not wish to be shown your own default music directory when prompting emms to play music. Please note that ‘;;’ are comments which need to be removed before replacing your default music directory in the below options. I do not use this option in my setup though.
;; When asked for emms-play-directory,
;; always start from this one
;;(setq emms-source-file-default-directory “/media/sda5/songs/”)
;;(setq emms-source-playlist-default-directory “~/Music/”)
STEP 8: You need to make sure if you have installed the mpg123 audio player. Emms uses mpg123 to play music from within the editor interface and without it, we cannot play music files in our editor. In OpenSUSE 11.2, I installed it using the Yast program. For Ubuntu, you can use the apt-get program.
STEP 9: You are all set to play music in Emacs now! Open up emacs and type ‘M-x emms-add-file’. You shall be asked to type the path of your music directory.
/media/music/songs/fav.mp3
STEP 10: You can start playing the fav.mp3 file by typing ‘M-x emms-start’
STEP 11: You can also enter the interactive emms mode by typing the path of your music directory in STEP 9 instead of pointing it to a single music file. For example, you can type /media/music/songs and then go into interactive mode by typing ‘M-x emms-playlist-mode-go’ and then using the arrow keys to select a track or file to play.
Some of the short cut keys in the interactive playlist mode are listed below:
`n’….Start playing the next track in the playlist.
`p’….Start playing the previous track in the playlist.
`s’….Stop playing.
`f’….Describe the currently playing track in the minibuffer.
`c’….Display the current track in the center of the screen.
`RET’..Start playing the track under point. Note that this is also
available with `
`q’….Put the interactive playlist buffer at the end of the list of all
buffers (ie. bury it).
A few more commands for your emms player:
emms-play-file …………. Play a single file
emms-play-directory …….. Play a whole directory
emms-play-directory-tree … Play a directory tree