How to listen radio from terminal?

mplayer

Try this.

mplayer http://80.237.154.83:8120

The IP-address of an online radio station can be found over at Xat radio search.

My result :

enter image description here

mplayer in IPv4 networks

If your router only works with IPv4, you will need to add the option -prefer-ipv4. More recent mplayer versions require this.

mplayer -prefer-ipv4 http://80.237.154.83:8120

Using VLC from the command line

As usual, VLC does it all. Use cvlc to run VLC on the command line.

cvlc http://80.237.154.83:8120
cvlc us.darkmatter.aac.48k.m3u 

VLC can also be invoked with a ncurses interface, as follows:

$ nvlc http://provisioning.streamtheworld.com/pls/CKFRAM.pls

or

$ vlc -I curses http://provisioning.streamtheworld.com/pls/CKFRAM.pls

Hit the H key for the much needed help.

Here is a screenshot of nvlc with a music playlist:

nvlc

mplayer in IPv4 networks

If your router only works with IPv4, you will need to add the option -prefer-ipv4. More recent mplayer versions require this.

mplayer -prefer-ipv4 http://80.237.154.83:8120

See below to read how to use mplayer with .m3u and .pls streams.

cmus also opens .m3u and .pls streams

Unlike mplayer, cmus also knows to open .m3u and .pls streams. This means less digging or "background work" to extract the stream URL from those files.

Furthermore, cmus looks nice and offers several views, a file browser and many configuration settings. cmus is available from the standard Ubuntu repositories. To get up to speed with cmus, first read the tutorial by typing the following command:

$ man cmus-tutorial

cmus

Open .m3u and .pls streams anyhow with mplayer

If you do not like cmus, or it is unavailable, mplayer can be made to do the same. For that purpose, I wrote the following mplay script:

#!/usr/bin/env bash
URL=$(grep -m 1 --null http "$1" |sed s/^.*http/http/ |tr -d '\r')
mplayer -prefer-ipv4 "$URL"

To navigate between directories of .m3u and .pls files, one could use the CLI file browser ranger, configured to call the above script for these file types. The struggle of setting this up pays itself back by being the fastest access method. This is what I personally use in a daily setting.

ranger

pyradio

Here is a nice write-up describing pyradio

Note that pyradio can also be installed and found as follows:

$ pip3 install pyradio
$ sudo find / -iname pyradio
$ ~/.local/bin/pyradio

moc

Then there is also moc. MOC (music on console) is a full-screen ncurses based console audio player.

MOC

Select a file from some directory using a menu similar to Midnight Commander, and MOC will start playing all files in this directory beginning from the chosen file. There is no need to create any playlists, even though MOC handles these as well.

mp3blaster

More details about yet another CLI music player, mp3blaster can be found here

$ sudo apt install mp3blaster

mp3blaster


There is indeed some "background work" to be done.

First of all, you will need to get hold of a URL that points to a real stream and not just a site that offers internet radio listening. This is probably the hardest part. You can search the station's website or google if there are any streams for that particular station. The stream URL is not the URL of a player on the station's website.

A URL might look like this: http://bbc.co.uk/radio/listen/live/r1.asx (BBC Radio 1) or http://www.bbc.co.uk/radio/listen/live/r1_aaclca.pls (BBC Radio 1, but a different URL) or http://www.ndr.de/resources/metadaten/audio/m3u/ndrloop5.m3u (N-Joy); it will (very likely) not look like www.live365.com.

All of the above may be played back easily using mplayer -playlist "<your url>", if that does not work with your stream, you can try mplayer "<your url>".