Delayplayer – Radio 4 synced to your timezone

Code now available on Github

There are many things UK expats miss when abroad. But while Marmite and Tunnock’s Tea Cakes can now be found in most corners of the world, the comforting presence of Radio 4 cannot. At least not in the same form as in the UK. You see although Radio 4 has been available live online worldwide for many years and its programmes are available on demand, anyone who’s grown up with it knows that it’s the timing of the programmes that’s important.

Starting with the Radio 4 UK Theme at 0545 (now discontinued) the Today programme at 0600, through to Book at Bedtime at 2245 and finally Sailing By and the Shipping Forecast at 0045, these programmes mark out the day. If you live in California, currently 7 hours behind London, you’ll wake up to The Afternoon Play and go to sleep listening to John Humphries grilling some hapless politician on Today, which just isn’t the same as hearing it while stumbling around the kitchen half asleep at 7am. You can listen to the UK Theme here:

In order to address this problem I’ve designed the ‘DelayPlayer’. This provides continuous feeds of Radio 4’s output synchronised with a number of timezones around the world. This is achieved by maintaining a rolling buffer of the last 24 hours of Radio 4’s output and taking delayed streams from various points in the buffer.

The system consists of two main parts. The first connects to the BBC’s live Radio 4 stream and records timestamped chunks of a few minutes to disk. The data is chunked to ensure the player never has to access a file that’s still being recorded and also to allow content older than 24 hours to be deleted easily. The second part is a simple web server which takes a single parameter ‘delay’ and streams the content from ‘delay’ minutes ago. For example, the URL for GMT-5 would be  ‘http://localhost:1234/?delay=300’. As this server is a bit experimental it’s exposed to the outside world via a more robust Shoutcast server running in relay configuration for a number of predefined timezones:

For timezones behind London a delay is added as expected. However zones ahead of GMT can’t listen in to the future (if they could I’d keep the racing results to myself), so the streams are synced by applying a delay equal to 24 hours minus their GMT offset. Admittedly this means that listeners in these zones are getting yesterday’s programmes, however the point of this system is to recreate the experience of listening to Radio 4 in the UK, and apart from news bulletins most of the output is fairly time-insensitive. The streams are accessed over a web interface driven from the BBC programme schedule API:


The streams aren’t perfectly synchronised. Buffering at the server and the client as well as errors in estimating the offsets into the stream files means that the audio you hear may be tens of seconds ahead or behind the actual local time.

As an indication of how important Radio 4 is, it is said that if transmissions ever cease then UK nuclear submarine commanders are to assume the nation has suffered a nuclear attack and should respond with a retaliatory strike. Think of that next time you’re listening to You and Yours.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInPin on PinterestShare on RedditShare on StumbleUponEmail this to someone