Thursday, February 12, 2009

HowTo: Play Mp3 on Terminal

Let's see, I have shared with you guys how to Browse the Internet using a Terminal, how to use Bittorrent on the Terminal, and how to Chat on IRC using the Terminal, how to Encrypt Files on the Terminal using CCRYPT, and now I am going to share how to Play Mp3s using XMMS2 on the Terminal.

It isn't much really and is fairly straightforward.

Heard any good Audiobooks lately? Get one free!For most of us, XMMS is really a Linux clone of the famous Windows application called WinAmp. I got confused myself when I tried to install XMMS2 and did not find any gui. Anyway, if you do want a GUI to have that WinAmp feel, do install Audacious.

For those of us who want to save precious screen real estate and just want to play music here is what we have to do:


1. Install XMMS2

dan@ubuntu$ sudo apt-get install xmms2

That's it.


Now most of us keep our mp3s in those things called folders. I for example, arrange my music folders according to Album. Let's start with an example:

I want to play this song: song.mp3 located in /home/dan/music/album1/song.mp3

To play that, I run this command:

dan@ubuntu$ xmms2 play /home/dan/music/album1/song.mp3

There is no visual feedback and no fancy schmancy Album art and graphics, that's just the way it is. Lean and mean.


I admit that the whole process is too long specially if you have to type in the path of the song every time you play a song. So, another way to resolve that is to add the whole Albums folder to the playlist.

Using our example above, we can do that by typing in the following command:

dan@ubuntu$ xmms2 radd /home/dan/music/album1

Now, to make sure that our playlist actually has something on it, and that the folder has been added, we execute this command:

dan@ubuntu$ xmms2 list
-> Random Artist - song (1:00)

    Random Artist - song2 (1:00)
    Random Artist - song3 (1:00)
    Random Artist - song4 (1:00)
    Random Artist - song5 (1:00)
    Random Artist - song6 (1:00)
    Random Artist - song7 (1:00)
    Random Artist - song8 (1:00)
    Random Artist - song9 (1:00)
    Random Artist - song10 (1:00) 

Total Playtime is 00:10:00

Take note of this sign: -> 
This shows you the currently selected track. It also shows the following information from left to right:

1. Artist name
2. Song Title
3. Time of Playback
4. At the bottom you'll see the Total Playtime which simply is the sum of all the playback times of each song in the playlist.

After adding the folder to the playlist, xmms2 would still have to be told to play the songs in its playlist. To start playing the songs in the playlist execute:

dan@ubuntu$ xmms2 play

Basically that's it. To show a list of commands that you could use simply do this:

dan@ubuntu$ xmms2   


Arn said...

hi, i'm using moc.. text based audio player too.. Hehehe

Derek said...

Hi, thanks for the great tip - however, I can't seem to get xmms2 to play anything other than "" - I assume it came with the install of xmms2.

No matter which song I tell it to play, it always plays that one?

Is there something I might have done wrong?

dannybuntu said...

Hmmm. Try this:

$ xmms2 list

Then look at the list of songs.

$ xmms2 play
$ xmms2 next

to get the next songs

dannybuntu said...

Oh and by the way, did you install the codecs? If not, do this:

$ sudo apt-get install w32codecs

Anonymous said...

How do I get MP3 to play?

I downloaded the MAD plugin, which is supposed to be a MP3 decoder, but I am unsure as to how it's supposed to be referenced by xmms2.

Any help greatly appreciated!

Anonymous said...


user@host:~$ sudo apt-get install w32codecs
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package w32codecs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package w32codecs has no installation candidate

Anonymous said...

everything is out there; you just have to know how to ask. my professor always say: "Google is your Friend!"

Change is permanent.

fleetkid said...

xmms2 is awesome for scheduling mp3 tracks to wake me up. thanks a lot people