When the BBC recently opened up their
iPlayer to more beta testers I signed up and got an invite quite quickly. I've been playing with it for a week or so now and it has been great to catch up with old episodes of Doctor Who which are currently showing on BBC 3!
The programmes are downloaded using the
Kontiki Delivery Management System. This is a peer-to-peer system and this is causing some users to complain quite vocally on the iPlayer messages boards. The problem is that rather than downloading TV programmes directly from the BBC each user is actually downloading shows from other users of the system. The delivery manager starts with Windows and cannot easily be turned off. This means that once you have downloaded a single TV show the software will continue to use your broadband connection to send the show to other iPlayer users. If not monitored this could cause users with a capped monthly download limit to quickly exceed their monthly allowance.
Knowing how the system works I'm quite happy to allow it to use a small amount of my bandwidth to provide the shows I've downloaded to other users. I did, however, want to install the iPlayer on my laptop so that I can catch up on TV when I'm away and this presents me with a problem. My laptop is often connected to networks where I don't pay the broadband bill or where peer-to-peer software is not allowed. So I needed a simple way of controlling the player.
Note that I'm not saying that everyone should stop uploading the TV shows they have downloaded. If they did the service would stop working properly and I would be unhappy. Rather I'm offering a solution for those people, like me, who have a genuine need to be able to limit the software's ability to upload data.The iPlayer message boards are littered with people suggesting ways to stop the iPlayer using your bandwidth but they all involve manually stopping the software, something I could easily forget to do. So being an inquisitive software engineer I've had a think and a little bit of tinkering later and I have a totally transparent solution to the problem. I think that this solution is OK within the Terms and Conditions you agree to when installing the iPlayer as Term 15 states that "When you use the BBC iPlayer library you shall not have the option to 'switch off' the peer-to-peer functionality". As the only time I use the iPlayer is when it is open and running then there should be no problems with stopping the peer-to-peer functionality service when I have choosen to exit the iPlayer interface. However, I will not be held responsible for your use of this solutuion.
For those of you who simply want to regain control of your computer you can download the
solution and instructions without reading any further. If however you are interested to see how the solution works then read on.
Firstly it's important to know that the iPlayer consists of two parts: the interface and a background service that actually controls the downloading and uploading of TV shows. We can easily make sure the user interface does not start with Windows from the iPlayer preferences. The second half of the problem is ensuring that the background service only runs when you have the iPlayer interface open.
The background service which handles the downloading and uploading of the TV shows is called KService. There are two parts to ensuring that it only runs when we want it to: making sure it does not run when Windows starts and stopping it when we exit the iPlayer. We can manage all of this from a command line, so we are going to write an old style batch file to implement this.
I'll show you the whole batch file first, then I'll explain what it does:
sc config KService start= demand
start /wait KHost.exe %*
net stop KService
OK so lets take the file a line at a time:
- this line configures the KService so that it only starts when it is needed. In theory we only need to do this once but we will do it every time we start the iPlayer just to ensure that it has not been reset to automatic.
- this line starts the KHost application, which is the iPlayer interface, and then waits for it to be closed by the user. This will continue to wait until the user chooses to exit the application by right clicking on the icon in the system tray and choosing "Exit". The %* at the end of the line means pass on any command line parameters the batch file had been given to the KHost application.
- by the time we get to the last line we know that the user has finished using the iPlayer so we stop the KService which stops the software from uploading or downloading any more data.
So save this as
KHost.bat
in the iPlayer installation directory alongside the real
KHost.exe
(by default this will be "C:\Program Files\Kontiki"). Now from a command prompt we can run the batch file and pass in the same arguments as the shortcut on the start menu uses and iPlayer runs correctly. Now this may seem like we have fixed the problem, but there is one thing left.
If you are browsing the list of TV shows that can be downloaded without the local application already running then it will be started as needed. From what I can tell it runs the KHost application with some different arguments to correctly embed it and then communicates with the running KHost process. To get our batch file to mimic this behaviour we have to be a little more clever and turn the batch file into a proper Windows application to replace KHost.
Firstly we need to move the existing
KHost.exe
file somewhere new as we will still need it. I choose to create an subdirectory called orig and put it in there. Now we also need to change the batch file so that it can find KHost in the new location. So we now have a new version of the batch file:
sc config KService start= demand
start /wait orig\KHost.exe %*
net stop KService
Now we just need to compile this batch file into an executable. For this we use an existing
compiler. Simply load the batch file we have built into the compiler tweak the options as you see fit (I checked both boxes but didn't bother with an icon) and then hit build and out will pop a executable version of the batch file named
KHost.exe
. Thats it, everything is now finished. Assuming you have followed the instructions properly the iPlayer should work exactly as it did before, but now the downloading and uploading will only take place when you choose to have the iPlayer loaded and will stop as soon as you choose to exit the interface.
So I can now safetly install the iPlayer on my laptop and not worry about what it's doing in the background when connected to networks on which I'm not allowed or don't want to run peer-to-peer software.
I'd like to stress that if you can you do not use this solution because if everyone stopped sharing the TV shows they had downloaded then the iPlayer would become useless -- something I do not want to see happen.