iPlayer in MythTV (the Easy Way)
December 1st, 2008I use MythTV as a media centre in my lounge, not to record TV, but purely for browsing and playing my collection of mp3s, and occasionally playing downloaded video clips. It also allows me to read rss feeds and their linked web pages using a remote from the comfort of my sofa.
One of the things I have wanted to be able to do for a while is use mythtv to watch BBC iPlayer content. There has been some attempts at making mythtv plugins for this purpose, but they have always been rather complicated to set up which has always put me off.
I discovered however, that the BBC has added rss feeds of the iplayer programmes to each of the pages in the iPlayer, so I decided to see if it would be possible to use these to get at the content frmo mythtv. These feeds on the BBC site are actually Atom feeds rather than rss feeds, and unfortunately mythnews (the rss plugin for mythtv) doesn’t support atom feeds. Luckily I found a handy online utility that will do an on-the-fly conversion from atom to rss: http://atom2rss.semiologic.com/ Using that I managed to create some new entries in mythnews that let me see the listings of iPlayer programmes for various channels.
So far so good, but when I select one of the items using the remote, it opens a mythbrowser window, but it gives a message saying that our version of flash is out of date and there is no easy way of upgrading it using the link provided. Luckily some helpful person has solved this one: http://www.nabble.com/Re%3A-Mythbrowser-0.21-flash-p16200963s15552.html
So now I was able to choose a programme and open a browser window, and the player appears. The next problem is that the programme does not play automaticaly, but you get a “Click to Play” prompt, and you need to click play to start the playback. As I am using a simple media centre remote for this, and don’t want to use a mouse that is a problem.
To solve this one, I had a look at what the other iplayer plugin had done: http://www.mythtv.org/wiki/index.php/BBC_iPlayer. I realised there is a package called xautomation that can be used to script mouse movements and clicks, so I decided to make use of this to click play for me. First, I used synaptic (or apt-get) to get the xautomation package. You can test it by opening a terminal and typing:
Your mouse pointer should move to the top left of the screen.
So, now I opened the iplayer page in mythbrowser and worked out the x and y co-ordinates of the play button. I then created a small shell script to move to the correct position, click, then move the mouse out of the way:
echo mousemove 200 560 | xte
sleep 1
echo mouseclick 1 | xte
sleep 1
echo mousemove 9999 9999 | xte
So, now I had a script to click the play button, I needed to associate it with a keypress on my remote control. Rather than so something to mythtv to get it to trap the event, I decided to use irexec which is a simple utility that comes with lirc (the remote control utility). So, I edited my ~/.lircrc file, and added:
remote = mceusb
prog = irexec
button = LiveTV
config = /home/adam/Scripts/iplayerStartPause.sh
repeat = 0
delay = 0
end
I needed to make sure irexec was running as a daemon when my server starts up (irexec –daemon). Now, whenever I press the “LiveTV” button on my remote (I was not using that button previously) my script gets executed and the mouse moves and clicks in the correct place.
So, now I have the ability to browse iplayer programme listings, select one and play it. I need to do some more work to add the ability to make the video full-screen, alter volume, etc, but for now it is great to be able to watch iplayer programmes from my sofa without having to fire up the laptop or PC