Skip to content

web radio streaming

Francois Corthay edited this page Jul 2, 2026 · 23 revisions

Web radio streaming can be done by simply paying an audio stream provided by the radio station in the form of an audio file (typically an MP3 or an AAC). Internet sites such as http://fluxradios.blogspot.com/ provide lists of such stream files.

The usage of multiplexed (dmix) ALSA sinks allows to mute the other audio sources and simply play the radio stream. Whilst mopidy and CamillaDSP allow to do so, snapclient seems not to.

Table of Contents

Radio stations

The radio station list can be provided in the system configuration.bash script:

source ~/Documents/RPi-multiroom-audio/configuration.bash
env  | grep 'RADIO_'

Edit the list and add station in the form:

# radio stations
export RADIO_OPTION_MUSIQUE='http://stream.srg-ssr.ch/m/option-musique/mp3_128'
export RADIO_ROCK_BALLADS='http://spoonradiorockballads.ice.infomaniak.ch/spoon-rockballads-hd.aac'

Reload the list:

source $AUDIO_BASE_DIR/configuration.bash

Test

If it has not been done yet, load the environment variables (adapt the path):

source ~/Documents/RPi-multiroom-audio/configuration.bash

On a local room amp

Check where mopidy is playing to (adapt the path):

$AUDIO_BASE_DIR/Management/showInstallation.bash
echo "Audio capture device is $ALSA_LOOPBACK_CAPTURE_DEVICE,$SNAPSERVER_LOOPBACK_SUBDEVICE"

Switch to local audio and pause mopidy:

$AUDIO_BASE_DIR/Snapcast/changeServer.bash -v localhost
$AUDIO_BASE_DIR/Mopidy/control.bash pause

Check the configured radio stations list:

env | grep 'RADIO_'

Play some radio station's stream (using ffmpeg or VLC):

alias play2loop="SDL_AUDIODRIVER='alsa' AUDIODEV='dmix:$ALSA_LOOPBACK_CAPTURE_DEVICE,$SNAPSERVER_LOOPBACK_SUBDEVICE' ffplay -ar $AUDIO_RATE -autoexit -nodisp -loglevel quiet"
play2loop $RADIO_OPTION_MUSIQUE > /dev/null 2>&1

cvlc -A alsa --alsa-audio-device dmix:Loopback,0,0 $RADIO_ROCK_BALLADS

Stop with a ctl-C.

Start playing the local mopidy again:

$AUDIO_BASE_DIR/Mopidy/control.bash play

Or switch to multiroom audio:

$AUDIO_BASE_DIR/Snapcast/changeServer.bash -v $MULTIROOM_SNAPCAST_SERVER

On the multi-room server

On the multi-room server, we want to multiplex mopidy and a command-line audio player in front of snapserver.

Pause mopidy:

$AUDIO_BASE_DIR/Mopidy/control.bash pause

Check the configured radio stations list:

env | grep 'RADIO_'

Play some radio station's stream:

RADIO_STATION=$RADIO_ROCK_BALLADS
AUDIO_SOURCE_LOOPBACK="$ALSA_LOOPBACK_CAPTURE_DEVICE,$SNAPSERVER_LOOPBACK_SUBDEVICE"
cvlc -A alsa --alsa-audio-device dmix:$AUDIO_SOURCE_LOOPBACK $RADIO_STATION > /dev/null 2>&1 &

Stop with:

pkill -f $RADIO_STATION

Resume mopidy:

$AUDIO_BASE_DIR/Mopidy/control.bash play

Switching to a radio station on a server

Switching to a radio station known in the configuration.bash list can be done with the help of a script:

# have a look at the known radio station list
$AUDIO_BASE_DIR/Management/streamRadio.bash -l
# tune to one of them
$AUDIO_BASE_DIR/Management/streamRadio.bash -s 'option musique'
# take a little time to listen, then tune to another one
$AUDIO_BASE_DIR/Management/streamRadio.bash -s rock
# take a little time to listen, then stop radio streaming
$AUDIO_BASE_DIR/Management/streamRadio.bash -e
The radio stations can be given lower case. Underscore characters can be replaced by spaces, yet requiring string delimiters. The name doesn't have to be complete :  a starting match suffices.

Controlling the radio streaming

The playerctl command-line utility allows to control media players.

Install it:

sudo apt install -y playerctl

Play with it:

playerctl --list-all
playerctl --player vlc pause
playerctl --player vlc play
playerctl volume 0.75
playerctl volume 1
playerctl metadata

Clone this wiki locally