I have just created and set up a script that starts an mplayer internet radio stream right at the startup (desktop) of the PI.

But with this set up, if the PI loses it's internet connection, the script must either be manually closed and re-opened, or the PI itself must be restarted (to run the startup script again).

I were wondering if someone here had any experience with a similar or the same problem and could possibly give me a pointer in the right direction?

The solution I am looking for is; If the PI loses it's internet connection, I wan't it to try to re-connect to the same stream URL untill it is successfull. I only have 2 days experience with Bash, Python and the PI, so any tips at all will be greatly appreciated!


Joakim (PHP-dev)


mplayer -loop 0 stream_you_want_to_play

-loop is not strictly designed for that, but it keeps trying to restart the stream after it is lost.

Works here for stream drops, as well as just plain disconnecting the Ethernet cable. Stream will resume after connection is re-established.

| improve this answer | |

I found an easy fix for this;

while true
    do mplayer http://YOURSTREAMHERE:8000/playlist.m3u -cache 1024
    sleep 2

Not the prettiest, but it does the job!


Joakim (PHP-dev)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.