At first, this may sound pointless. After all, aren’t there dozens of perfectly good GUI music apps out there? Haven’t we all found something we like, or at least don’t hate? Perhaps that’s true, but how much happier would you be if your music app of choice used a whole lot less resources? Or what if you could type in a command on your laptop from anywhere, and have music start playing from the speakers on your desktop? If you’re in to pranks, that works just as well on a friend/co-worker’s computer. Today’s topic is mpg123, an app which can (among other things) make a great GUI-free media player.
Get the app
Just about any Linux distribution with online repositories will have this package available, normally as just mpg123. Ubuntu users can find it in the Software Center or from the command line with
sudo apt-get install mpg123
In the event that your distribution does not have binaries available, you can download the source code here.
A single track can be played in a simple and pretty obvious way, just mpg123 followed by the filename, as in:
Which will play the single track from start to finish with output something like this:
You can also use shell wildcards to send mpg123 several files at once. The simplest example is to use the above method, but replace the filename with a quick and easy *.mp3.
To set your playlist to shuffle mode, just add a -Z in there
Optionally, you can use normal bash redirect characters to feed mpg123 a list of filenames.
ssh username@my-remote-machine-address mpg123 -Z -@ < myplaylistfile
The -@ flag tells mpg123 to treat the following input as a playlist (it's the shortened form of --list), and the < is a standard bash redirect to pull the text out of the file and use it as mpg123's input.
Remote Play Control
This isn't exactly a "feature" of mpg123, it's more like a side effect, but for this author, it's the most handy thing about this application. You see, regular readers or Linux pros probably already know about SSH, the fantastically useful remote shell application with 1001 uses. Since SSH gives you a shell on a remote machine, you can run programs on that remote machine. As mpg123 is just another shell application, the normal rules apply. If you SSH into a machine and run mpg123, it will play out that machine's speakers.
This is great for me. If I'm sitting on the porch with my netbook on a fine summer day, I can SSH into my desktop (which is hooked up to a home theater) and run a mpg123 to start my music without ever leaving the chair, or being forced to deal with the low-quality underpowered netbook speakers. Just SSH into the machine and run mpg123 as if you were sitting at the keyboard, as in
ssh username@my-remote-machine-address mpg123 -Z --@ < myplaylistfile
If you like tag-based music libraries, album art, device synchronization, and other fancy features - mpg123 is clearly not a solution for you. In fact, I doubt there are many people who'd want to use this as their primary music player on a day-to-day basis, but there are certainly times when it comes in handy. We've explored just a few of them, and I'm sure our readers can come up with quite a few more. If you've found a great use for mpg123, please let us know in the comments.