BBC iPlayer, DLL Hell, Tears and Sweat

The first entry in this blog; right, I’d better make it good. I’ll skip the mic check.

I’m sure you’ve come across the majesty of the BBC iPlayer? It provides two options for viewing their programmes. Either you can install their download service, or you can watch them streamed through your web browser.

Being an impatient person when it comes to waiting for downloads, It’s been my preference to go for the streaming option.

Now streaming video content is hardly anything new, but since the early days of YouTube, I’ve been plagued by the problem of the monitor switching its self off half way though that Salad Fingers episode. Even worse, the computer sometimes hibernates if I don’t wiggle the mouse every so often.

It’s true that I could just disable these options in the Power Options control panel, but I shouldn’t have to! I like the fact that if I leave my computer on over night, it powers down by its self. But, I also want this eco-friendly behaviour to cease when I’m streaming stuff from the iPlayer.

Then it hit me; I can program! Can’t I just write something to solve this little inconvenience? It’s also a good bet that if it’s bugging me, there’s at least ten other people out there in Beeb* land who are in the same boat, and could benefit from a tool like this as well.

My first consideration for this simple application was which programming language to use. I started by considering C# and .NET.

My opinions on .NET are pretty much sum up to that “it’s a nice idea… in theory”. It gives you a choice of languages for the same architecture in a way that Java doesn’t (although, this has been changing). Visual Basic is a good language for beginners and RAD (Rapid Application Development), and C# is at least as powerful as Java.

As a language, I really like C#, and I thought that seeing as I was writing an application which would be accessing the Windows API, using .NET with C# would be a logical choice. I should have stayed in bed.

My first head on encounter with Windows Registry left me feeling quite proud of myself. I’d managed to work out where Windows stored its power settings, and managed to even write and read my own program’s settings. Yes, proud I was, but, what’s that they say about pride coming before a rope-less bungee jump?

When I finally took a look at the settings power setting contained within the registry, I discovered that they were stored as a binary blob. Now, binary-blobbish is not a language I can speak, and so I familiarised myself with the brick wall I’d just hit.

Eventually, I had a revelation; a revelation that probably would have come earlier if I’d sat down and thought about the problem before I’d began gleefully bashing away at the keyboard. The revelation? Why don’t I just have the program send a system event like a mouse nudge or a key-press to keep the computer awake?

So simple was this idea, I thought I’d been saved from more registry hell. Instead, I’d be thrown out of registry hell and into DLL hell. To be honest, I never was much of a systems level programmer; I used to think that ‘forking’ was something you did with another consenting adult.

(for those of a technical/masochistic persuasion, accessing a .dll library from C# involves a strange import statement, followed by a declaration of prototype functions to bind to these unmanaged library elements. You will also need a couple of drams of whiskey, and someone to comfort you when it all goes wrong.)

During all this, my flat-mate wandered in. Noticing the drying blood on my laptop keyboard, and the head injuries, he asked me if I’d just gott dumped. I corrected his appraisal of the situation, to which he asked me the obvious question: “Why aren’t you doing this in Java?”

Now, Java is a language I know and love. But, I had made the assumption that it wouldn’t be very good with accessing things from the Windows API. In response to my defeatism, he blessed me with three magical words: The Robot Class.

This class from the Java API allows you to generate system input events, such as a mouse nudge. Just what I was looking for! Back within my comfort zone, I stopped crying. It only took me ten minutes to have the program I wanted. “Tonight I will sleep well!”, I thought to myself.

So, what did I gain from my experience as a headless but well intentioned chicken? Well, I now have this theory which explains why resources for learning .NET technologies are often difficult to come by when you have a specific issue that needs resolving.

My hypothesis goes as follows: Companies spend vast amounts of money sending their employees on the much coveted Microsoft Certification courses. It’s my understanding that they cost a bomb, and owning one can increase your chances of employment within the industry significantly.

With so much money at stake, is it in Microsoft’s interests to make it easy to learn their technologies for free?

Furthermore, Imagine that you’d been on one of these courses. You’d slaved away to pass their exams, and maybe even had to sell three internal organs to cover the costs. Would you want to part with this hard earned knowledge with some noob on an internet forum? Wouldn’t you feel a little defensive, and maybe even a little smug that you were better than the average Joe (or Josephine) programmer?

So, in the end, I’m a little more cynical, but also a little wiser. And, the head wounds are healing nicely.

(The application I was attempting to make is available to download here)

*The ‘Beeb’ is an affectionate nickname for the BBC.

3 thoughts on “BBC iPlayer, DLL Hell, Tears and Sweat

Add yours

  1. That sounds about right — java has some really useful stuff hidden away, and some even more useful stuff that can be downloaded like java3d, it’s sometimes pretty hard to find though.Out of interest, what event did you end up sending windows to keep it alive?

  2. “Noticing the drying blood on my laptop keyboard,”


    From a layman’s perspective, I would have tried to use “< HREF="" REL="nofollow">Autohotkey<>” and write something, as I’ve had < HREF="" REL="nofollow">some good success with it<> in the past, but don’t you just find things like that so annoying!?

    If it helps, I use the most excellent website < HREF="" REL="nofollow"><> to “reveal” the actual RealMedia (.rm) links to the BBC’s radio shows, which I then download and convert to mp3 using an ancient copy of “Streambox Ripper”.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by

Up ↑

%d bloggers like this: