streaming radio on a Raspberry Pi

I migrated the web server that runs this blog to my new 512MB Pi, so was looking for a use for my original 256MB one. Although I have a perfectly good radio in my bedroom I like the idea of streaming radio to the command line, and maybe using the Pi as an alarm clock with some cron scripts.

A bit of Googling suggested that mpg123 and their like will struggle with the sort of playlist files and stream encoding used by the BBC, and so mplayer looked like the best candidate to have working stream with minimal fuss:

sudo apt-get install mplayer
mplayer -playlist ""

The above saw mplayer throwing some errors about unavailable pulse audio drivers. I added an argument to force use of the alsa drivers:

mplayer -ao alsa -playlist ""

Now mplayer seemed to fetch the stream ok and looked like it was playing, but I heard no sound. (I’m using a portable speaker connected to the Pi’s headphones socket). I checked the volume level in Alsamixer, and that was fine. Back to Google again and the Raspberry Pi troubleshooting guide suggested that I could force audio to route via a particular output – in this case the one I wanted for the headphone socket was:

sudo amixer cset numid=3 1

Fired up mplayer again and yay, Radio 4 🙂 Next step is to add some cron scripts to start and stop the radio in the mornings.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s