4

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!

Thanks!

Joakim (PHP-dev)

Joakim Refs
  • 51
  • 1
  • 4

2 Answers2

3

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.

jaaasgoed
  • 31
  • 2
1

I found an easy fix for this;

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

Not the prettiest, but it does the job!

Regards

Joakim (PHP-dev)

Jacobm001
  • 11,904
  • 7
  • 47
  • 58
Joakim Refs
  • 51
  • 1
  • 4