Automatic Play USB if not network

On a Raspberry i have set PI Muisic Box that “plays” a certain Webradio when switched on, my question is: if the network connection fails or is interrupted, it is possible to switch automatically on the USB key or on the sd card, like a sort of redundance/backup audio?
Many thks

Hi,

Here I use something like that:
1 - MPD playlists, example:
a-webradio1
b-webradio2
c-webradio3
d-music1fromusbdisk
e-music2fromusbdisk
f-music3fromusbdisk

Them some script running on crontab, checking every 1minute.

The script use error on mpd.log


#!/bin/bash
export MPD_HOST=192.168.1.1
export MPD_PORT=6600

If your daemon is MPD

#musica=tail -10 /var/log/mpd/mpd.log | grep -c slow
#falha=tail -10 /var/log/mpd/mpd.log | grep -ic failed

if your daemon is Mopidy

musica=journalctl -u mopidy.service | tail -10 | grep ERROR | grep -ic gstreamer
#falha=journalctl -u mopidy.service | tail -10 | grep WARNING |grep -ic problem
falha=journalctl -u mopidy.service | tail -10 | grep ERROR |grep -ic error

tempo=mpc | sed -n 2p| tr '/' ' ' | awk '{ print $4}'

if [ $musica -eq 1 ]
then
echo $musica
echo OK
mpc stop
sleep 3
mpc play
sleep 5 && mpc play
exit 0
elif [ $falha -eq 0 ]
then
echo “Tudo Ok”

mpc volume 65 && mpc stop && sleep 3 && mpc play

    mpc
    exit 0

else
echo “Zuado!”
mpc stop && sleep 5 && mpc play
sleep 10 && mpc seek $tempo && mpc play
exit 0
fi

exit 0


It’s not a beautiful script… but works fine here over years…

Hope this can help!