Mpg123 is really cool audio player. Decode libraries are written in assembly language with SIMD instruction’s optimize. So, it’s really fast. It’s available for both Windows and Linux. Mpg123 is a console audio player, so if you prefer to write scripts and don’t like the GUI, this is what you need.
It is easy to install:
sudo apt install mpg123
Now, let’s try it. Just type the way to our music. Something like that:
How To make mpg123 work with pulseaudio
If you have a pulseaudio installed, there are bugs in mpg123, which appears when something application using pulseaudio. So you need to run mpg123 with support for it:
mpg123 -o pulse ~/Music/SomethingTrack.mp3
Now, problems with pulseaudio should be solved.
How to shuffle or randomize tracks
If you have a directory where are many mp3 files, you can mix it and play them in a mixed order:
mpg123 -o pulse -C -z /home/Roman/Music/*.mp3
- -o pulse means run mpg123 with pulseaudio compatibility
- -C means run mpg123 with keyboard hotkeys compatibility (I will show you that later)
- -z means shuffle the file list
- *.mp3 means all files with .mp3 extension in Music directory
When you succeed, the files should start playing in a mixed order.
If you want randomize tracks, just use -Z option (-z is shuffle).
Can play forever, the track list has no end:
mpg123 -o pulse -C -Z /home/Roman/Music/*.mp3
When you play a lot of files, you can simply switch to the next or previous track.
Remember we enable -C option? It includes this feature. This includes keyboard control. Here are some keys I like to use
- Space – to pause track
- F to go to the next track
- D to go to the previous track
- B to return to the beginning of the track
- Shift + ; to rewind the track forward
- ; to rewind the track back
- Shift + = to increase the volume of the track
- – to decrease the volume of the track
How to listen to the radio with mpg123
Mpg123 supports http protocol. So, you can type it directly. For example,
247 the mix – 80’s, 90’s and Beyond! radio:
mpg123 -o pulse http://184.108.40.206:7304/
So, it works. Here is terminal output:
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3 version 1.25.10; written and copyright by Michael Hipp and others free software (LGPL) without any warranty but with best wishes Directory: http://220.127.116.11:7304/ Terminal control enabled, press 'h' for listing of keys and functions. Playing MPEG stream 1 of 1: ... ICY-NAME: 247 the mix - 80's, 90's and Beyond! ICY-URL: http://www.shoutcast.com MPEG 1.0 L III cbr192 44100 stereo ICY-META: StreamTitle='SIMPLE MINDS - WATERFRONT';StreamUrl='http://www.247themix.com'; ICY-META: StreamTitle='JOE WALSH - A LIFE OF ILLUSION';StreamUrl='http://www.247themix.com';
To find the server’s IP address and port, you need to go to the site of the radio that you want and download the m3u file in which it is specified, in the future I will show how to do it.