Bleuwinter
Windows to my life

mpg321

mp3,cli,Ubuntu,Linux

mpg321 is a command-line mp3 player.

Why & when to use it?
* On old computers
* If your GUI stops working and you need some music while you are solving the problem
* Play music from your server
* Learn command line and practice it
* For fun

How to install it on Ubuntu?:
Open the Terminal (Applications → Accessories → Terminal) and type the following command:

sudo apt-get install mpg321

Key in Y and press Enter when you’re asked to install other required packages.

How to use?
Access the help menu:
Open the Terminal (Applications → Accessories → Terminal) and type the following command:

mpg321 --help

You will get a list of codes which you can use with mpg321.

--verbose or -v Increase verbosity
--quiet or -q Quiet mode (no title or boilerplate)
--gain N or -g N Set gain (audio volume) to N (0-100)
--skip N or -k N Skip N frames into the file
--verbose or -v Be more verbose in playing files
-o dt Set output devicetype to dt
[esd,alsa(09),arts,sun,oss]
--audiodevice N or -a N Use N for audio-out
--stdout or -s Use stdout for audio-out
--au N Use au file N for output
--cdr N Use wave file N for output
--wav N or -w N Use wave file N for output
--test or -t Test only; do no audio output
--list N or -@ N Use playlist N as list of MP3 files
--random or -Z Play files randomly until interrupted
--shuffle or -z Shuffle list of files before playing
-R Use remote control interface
--aggressive Try to get higher priority
--help or --longhelp Print this help screen
--version or -V Print version information

Example:

mpg321 -q filename

This code allows you to play a song without any details.

mpg321 -v filename

This code allows you to play a song with information of the file.

Of course it would be ridiculous to play music one by one file so we have to create playlists:

Open the Terminal (Applications → Accessories → Terminal) and type the following command:

(Find the location of your mp3 files by the command dir, cd, and cd...)
dir : Shows a list of all the files available in that directory
cd folder: Goes to folder directory (Replace folder with the name of a folder that you want to access)
cd.. Goes to previous directory

Example: Your music is located in /home/yourusername/Music so you should type cd /home/yourusername/Music

Then, create a playlist of all songs in this folder:

ls *.mp3 > playlist.txt

or create a playlist based on artist(Example abz)

ls | grep abz > abzplaylist.txt


*Tips: Replace abz with the artist name

To play the playlist:

mpg321 --list playlist.txt


Play it randomly:
*Little shuffle mode (Plays every file once in a random order)

mpg321 -z --list playlist.txt


*Big shuffle mode (Plays a random file and then plays another random file. mpg321 will go on until you stop it.)

mpg321 -Z *

Resources:
Command Line Warriors
Linux Dev Center

Its alternatives:
1. Amarok (If you’re using KDE/Kubuntu as it suites the theme and environment)
2. Songbird – My favourite, read the review.
3. Audacious – Lightweight and Winamp like, read the review.
4. Rhythmbox – It comes pre-installed on Ubuntu
5. Listen Audio Player
6. Exaile – Music Player for GTK+
7. Banshee – Play music and videos. Sync your ipod and G1.
8. orpheus – another Command-Line Interface(CLI) audio player

One Response to “mpg321”

  1. Cheers for this blogpost, I have learned a lot more now about dir of mp3’s. My favorite is a open directory I found somewere on google. It has storaged thousands of music files. I have added the link in that website url option. I hope to see a lot more posts from you!


Leave a Reply