BBC iPlayer – Emergency Keyboard Shortcuts

I’m a massive fan of the BBC iPlayer, but although it allows access to unparalleled content, it isn’t the most convenient interface for people who, like me, prefer to have it playing in the background and control it with shortcuts, rather than pointing, clicking, stretching, squeezing or otherwise manipulating it.

The content is delivered through an embedded flash app., and there are no (public) interfaces to drive it from the command line for simple activities such as pause / play, or flipping between live streams:

BBC iPlayer - Popup Player Window

But there’s a neat(ish) solution until someone wakes up and implements this sort of thing properly, that allows you to control a number of the functions on the player window interface in some circumstances:

  • You need to be running a Linux variant of some kind. I go with Ubuntu 10.04 LTS
  • Your chosen window manager should ideally support the concept of multiple desktops. I use a very minimal tiling window manager called i3, but most modern managers and more graphically pleasing managers will do anyway.
  • Your chosen window manager should allow you to bind shortcut keys to commands, in particular shell scripts
  • You need to install the xdotool utility.

The basic premise is:

  • You startup the iPlayer interface and ensure that the player window is positioned on it’s own desktop at the same position each time
  • You write a small shell script that uses xdotool to switch to the desired desktop, move the mouse to the correct position over the player control and mouseclick the control
  • You bind a command to run that script to one of your shortcut keys.

This is the script that I use, pause-iplayer.sh, bound to WindowsKey-L

#!/bin/bash
# set focus to iplayer desktop
i3-msg 4
#
# Move to player and ensure focus is on embedded player
#
xdotool mousemove 1465 430
xdotool click 1
sleep 0.25
#
# Now move and click play / pause
#
xdotool mousemove 1465 487
xdotool click 1
sleep 0.25
i3-msg 1

The i3-msg commands send commands to the i3 window manager. in this case, they flip to the dedicated desktop to perform the click, and back to the first desktop when it’s done. In the case of more standard window managers, xdotool can send the keyboard shortcut to switch desktops to the manager in a similar fashion.

xdotool mousemove 1465 430 moves the mouse to an inactive area of the iPlayer embedded control, then xdotool click 1 sends a left button click to it. This step ensures that the embedded player control has focus. If it doesn’t have focus, the click may be wasted and this makes sure it isn’t.

xdotool mousemove 1465 478 moves the mouse over the play / pause button. xdotool click 1 delivers the payload click.

The sleep 0.25 commands pause to allow the window manager to catch up with events and ensure that the correct events get sent to the correct desktop and window. There can be the odd hiccup if there’s a lot going on and you leave no pause.

So pretty simple. A bit of flickering, but it doesn’t interrupt your flow. Lots of room for improvement (I should really push and then pop the current desktop and mouse position for instance, and add shortcuts to flip to the live stations) but for me, not worth the additional effort; pausing when I need to answer the telephone covers 90% of my requirements.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s