mcfleeg
Posts: 8
Joined: Fri Oct 04, 2013 5:11 pm

Reliable shoutcast playback

Fri Oct 04, 2013 5:29 pm

I'm looking for a way to get the Pi to play back a ShoutCast stream with high-reliability. What I mean by this is if the stream goes away, or there is a network issue, or whatever...the Pi continually tries to grab the stream until its successful and keeps right on playing it.

I started by setting up automatic login, and launch mplayer from an entry in .bashrc. It seems to work, but for some reason it stopped working (okay, lame...I didnt have a monitor hooked up to see why it died)...so I issue a Ctrl-D to log out, and it auto-logs back in and starts working again.

I guess the question is...what is the most reliable way to continually play a Shoutcast stream, in more general terms? Is mplayer the right choice?

Thanks!
-Lee

mcfleeg
Posts: 8
Joined: Fri Oct 04, 2013 5:11 pm

Re: Reliable shoutcast playback

Fri Oct 04, 2013 7:19 pm

I guess may be I should use mpd?

Would this be the most reliable way to always play the one shoutcast stream that I want it to play?

mcfleeg
Posts: 8
Joined: Fri Oct 04, 2013 5:11 pm

Re: Reliable shoutcast playback

Fri Oct 11, 2013 8:21 pm

Okay, I got mpd/mpc working, however it seems that just like mplayer, mpd will NOT automatically reconnect to a shoutcast stream after a "prolonged" network error/outage. By prolonged, this is generally only around a few minutes. Easily replicated by simply unplugging the eth0 cable for >60secs or so.

As a work around, I'm using a cron job to execute an "mpc next" command every 30 minutes. The work around sucks because it causes the audio to have dropout for about 1/2 second (when everything is playing fine). I'd really like a better solution for reliable restart after network error.

Anyone have any better ideas?

Thanks.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Reliable shoutcast playback

Fri Oct 11, 2013 8:48 pm

I'm surprised you're having shoutcast issues I regular use my Pi to stream mp3/aac audio around my home using Music on Console and an FM audio transmitter dongle.
I can't say I've ever experienced complete network drops myself but if I wanted to provide continuous playback then I just need a script running in a loop to keep things in check.
This would wait 30 seconds then request the playback status from moc, if the stream has stopped I could force it to perform a reconnection.
Alternatively I could also check my network status with the netstat tool and see if the shoutcast server is connected or stuck in SynSent mode.

Richard S.

mcfleeg
Posts: 8
Joined: Fri Oct 04, 2013 5:11 pm

Re: Reliable shoutcast playback

Sun Oct 13, 2013 3:43 pm

Thanks Richard for your reply. I'm a bit of a novice when it comes to scripting, so if you have any scripts to share I would appreciate it. I currently have "mpc next" in a cron job that runs every 30 minutes. Not the most ideal, because when its playing fine, and you run mpc next, the audio drops briefly (as you would expect)...yeah, not exactly sure why I have such networks issues, but seems to be about every other day it drops for whatever reason (maybe my cable provider, dont know for sure).

Thanks!
-Lee

zaiper
Posts: 2
Joined: Fri Aug 24, 2012 3:33 pm

Re: Reliable shoutcast playback

Mon Mar 03, 2014 2:42 pm

Hi!!

I was trying to do something similar but I still haven't been able to check if the pi is playing music or not, did you find any solution?

Best Regards!

Return to “Graphics, sound and multimedia”