MPG123 audio player in terminal.

Add MPG123 Terminal Music Player to Raspberry Pi, Linux

by Lewis Loflin

MPG123 is a fast console MPEG Audio Player and decoder library. It works in a terminal. It consumes almost no system resources and I use it for background music on my desktop.

I works on standard Linux and Raspberry Pi. To install:

~ $ sudo apt-get install mpg123

The website is

How to Use

Open a terminal and type the following and you get the above assuming folder Music is in your home folder and has mp3s:

~ $ aterm -e mpg123 -CvZ ~/Music/*.mp3

With aterm it can be any terminal in your system such as lxterminal in Raspberry Pi.

Let's set this up as a bash script and save in your $HOME/bin folder. Open a text editor:

# -C, --control Enable terminal control keys.
# -v --verbose
# -Z random loop
lxterminal -e mpg123 -CvZ ~/Music/*.mp3

Note you can use any terminal you have such a aterm, xterm, etc.

Save and close.

This will play every song at in the directory random forever. Leave out -Z and it will play every song in the directory in alphabetical order then exit.

The -C allows one to display a help menu by typing h.

Python based audio control box.

Above is my Python audio menu.

Save the above as (or rename it anything other than mpg123) in you bin folder or /usr/local/bin. Add the command you your menu.

Make the file executable:

~ $ sudo chmod +x

Below are various terminal commands. Some may not working depending on how the binaries were compiled.

[s] or [ ] interrupt/restart playback (i.e. 'pause')
[f] next track
[d] previous track
[b] back to beginning of track
[p] pause while looping current sound chunk
[.] forward
[,] rewind
[:] fast forward
[;] fast rewind
[+] volume up
[-] volume down
[r] RVA switch
[v] verbose switch
[l] list current playlist, indicating current track there
[t] display tag info (again)
[m] print MPEG header info (again)
[h] this help
[q] quit banner.

Web site Copyright Lewis Loflin, All rights reserved.
If using this material on another site, please provide a link back to my site.