Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at


hpr3014 :: A Headless Raspberry Pi Streaming Radio

I use a Raspberry Pi to make a streaming radio device for my pillow speaker.

<< First, < Previous, , Latest >>

Thumbnail of Jon Kulp
Hosted by Jon Kulp on 2020-02-20 is flagged as Clean and is released under a CC-BY-SA license.
Raspberry Pi, Internet Radio, Streaming Radio, Radio, Streaming Audio, Ubuntu, Ubuntu Server. 4.
The show is available on the Internet Archive at: https://archive.org/details/hpr3014

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:17:48

general.

In this episode I talk about how I used a Raspberry Pi to create a streaming radio device to feed my pillow speaker. This is something I used to do with clock radios and later a satellite radio, but in an effort to decrease monthly subscription costs for services I did not use optimally, I discontinued my satellite radio subscription about a year ago. This new free solution is an excellent substitute for Satellite Radio so far, since I was mostly listening to this same channel on the Sat Radio but paying about $12 a month for the privilege. The device I’m using is a Raspberry Pi 2 Model B with Ubuntu Server. My barrier to this project in the past was not being able to find the URL for the stream I wanted but I discovered you can find it easily if you use Firefox with Video Download Helper to reveal the URL on a page with media playing (in this case it’s from TuneIn):

https://XX.XXX.XXX.XXX/radio-stationmp3-48?session-id=af1b271fefba04b650f8e253c6b253bd&source=TuneIn

Strip off everything after the 48 to get raw URL:

https://XX.XXX.XXX.XXX/radio-stationmp3-48

Command to play stream with mpg123 on the Pi. Using the -q option to suppress output:

mpg123-pulse -q https://XX.XXX.XXX.XXX/radio-stationmp3-48 &

Once I figure out the command that plays the stream I want, I save the command as an executable script in /home/$user/bin.

Using the “Radio”

To start playing a stream you first have to SSH into the RasPi. This is easy from a laptop using any terminal emulator. I use pubkey auth so I don’t have to type a password every time. On my phone I use ConnectBot. Once I’m into the Pi I run the radio commands from CLI like espn or kmfa or krvs. To stop playback I kill the process with pkill mpg. I have a 3.5mm audio splitter Plugged into the headphone jack of the USB audio interface. In one side of the splitter I’ve got an old pair of earbuds where one side didn’t work, with the working earbud under my pillow. That’s my pillow speaker. On the other side of the splitter I put the audio cable for an FM transmitter, so that I can use an FM radio to listen to the stream while I’m walking around the house.

Click the image below to see pictures of the setup.

Raspberry Pi Radio


Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2020-02-20 17:18:38 by b-yeezi

Trying this tonight

Thanks for the show. I will be trying out mpg123 on one of my pis tonight!

Comment #2 posted on 2020-02-20 23:04:07 by Jon Kulp

Still Streaming with URL Update

Thanks for the comment, I hope the Pi+mpg123 suits your needs. Mine is still working perfectly after about a month, though I had to update the URL for one of the streams. I love my Pi radio!

Comment #3 posted on 2020-02-20 23:04:45 by b-yeezi

Issue with mpg123

I tried to use mpg123 with a remote stream and found the following problem on Ubuntu 19.10:

The URL MUST start with http:// and not https://, or else it looks to play a local file, and you get the error, "file access error, (code 22)". If stream redirects http to https, your stream should play. If it doesn't, you may be out of luck. For instance, I picked a random podcast on iTunes and it failed to redirect. On the other hand, using a file from HPR works just fine.

Comment #4 posted on 2020-02-21 12:07:07 by Jon Kulp

HTTP not HTTPS

You're right! I found the same thing but forgot to mention it in either the recording or the show notes. So far all of the streams I listen to work with the http prefix, though. I seem to recall that command-line VLC (cvlc) can play streams with https but I may be wrong. I'm on my phone at the moment and can't verify.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
What is the HOST_ID for the host of this show?
What does HPR mean to you?