november 29, 2015
Church Rabbit
Here in the Netherlands, we have a service called "Kerkomroep". This service is for people who cannot visit the church, but still want to be involved and listen to (part of) the services on Sunday.
In the past, they could take a paid subscription to "Kerkradio". This service used a plain old telephone line to send its signal to a radio with an AUX input. But now, in the modern age, the church is sending its signal to us using the (MP3) streaming servers of "Kerkomroep.nl".
Every church attached to Kerkomroep has a computer that is connected to the sound system of the building. This computer sends its information to the Kerkomroep servers, and we can listen to these streams, live.
Normally, you will have to buy a tablet or smartphone, an internet radio or rent a special device to listen to Kerkomroep. I wanted to know if it is possible to use a Karotz as a cheap receiver for this.
In my village, there are two churches with two buildings, each with its own stream. One week, the service is in building A, the next week the service is in building B. I wanted to create a simple solution that picks one of the buildings automatically.
It is possible to play a sound on the Karotz from a bash script using command "PlaySound" or "PlaySoundEx" (that is, when "utils.inc" is included). PlaySound uses "madplay", and PlaySoundEx uses "mplayer" to play a sound or stream. MPlayer is a multimedia player for Linux. It can play content from the internet. Nice thing about MPlayer is that it will follow a redirect. And that is the technique we're going to use to play our Kerkomroep stream.
I've created a webservice on FreeRabbits that accepts an URL with unique church codes as a query parameter. This webservice is called from the Karotz in a bash script like this:
source /www/cgi-bin/setup.inc
source /www/cgi-bin/utils.inc
KERKOMROEP_URL="http://www.freerabbits.nl......"
KillProcess SOUNDS
sleep 1
PlaySoundEx $KERKOMROEP_URL 1
PlaySoundEx will call MPlayer and pass the URL, and MPlayer will send the http request to FreeRabbits and wait for some media to return, or will follow a redirect. When FreeRabbits receives these codes, it will first ask the Kerkomroep-website which churches are online and broadcasting live. This request will return a list of URLs with currently live streams, where every URL contains a unique church code. After this, FreeRabbits will try to find the first stream that matches one of the codes. If found, it will do a redirect to the found stream. If there is no match, it will redirect to a static MP3 file on FreeRabbits.nl that will play a "No broadcast at the moment, try again later" message.
I have tested the bash script on the Karotz. This works like expected. I changed the single click of the button to run this script, so no need for a browser to start the procedure.
If you are interested in using this Freerabbits webservice, let me know and I will send you information how to call it.