Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8015

Graphics, sound and multimedia • Restart web stream playback on loss of internet connection

$
0
0
Hi,

I'm using a Raspberry Pi Model 4B as an unattended audio player to play back a web stream. I have a bash script set to run at login which starts VLC in the background with the stream URL, so that the stream will start automatically when the Pi boots up. My problem is occasional Internet dropouts will cause VLC to stop and not resume. I then have to log into the Pi and restart VLC (or reboot the Pi). This then means the audio could be dead for a while if I'm not around to notice it.

The recommended solution to this (e.g. https://askubuntu.com/questions/318537/ ... deo-stream) is to use the --loop parameter to play the stream in a loop, so if the stream ends, it should automatically restart. This seems to work if the stream itself drops out, but doesn't handle the "loss of internet" scenario. VLC doesn't seem to see this as the stream ending, so will just sit there doing nothing rather than restart. Another recommendation is to use a while true loop in the bash script to automatically restart VLC, but this doesn't work either as VLC does not actually close.

I have tried mplayer -loop 0 as an alternative to VLC but it has the same problem - it will hang indefinitely when the internet goes down rather than trying to restart.

I expect the solution is some script that monitors the internet connection and restarts VLC when needed. However even the recommendations I've seen for this (e.g. using systemd events) won't work as they only detect loss of LAN connection, not loss of internet. The LAN is usually quite reliable, it's the internet connection that is giving me trouble.

I'm sure I could write a bash script to ping a server (ideally the stream server) and trigger VLC, but I wonder if there is an already existing tool that will do this rather than re-inventing the wheel?

Thanks

Statistics: Posted by atom — Wed Sep 03, 2025 6:38 pm



Viewing all articles
Browse latest Browse all 8015

Trending Articles