I use the Clementine media player on my Linux desktop machine at home for music (mostly a couple of Internet radio stations) and I wanted to have an easy way to control it. I have a wall mounted Android tablet which I use as an interface to the OpenHAB home automation system so that seemed like an obvious choice.
I don’t run OpenHAB on my Linux desktop so I needed a way for my OpenHAB server to communicate with it. Clementine has two ways you can control it remotely – a proprietary method based on Google Protocol Buffers and a more generic one using the D-Bus based MPRIS. I chose the later because it looked simpler and could easily be adapted to other media players that provide an MPRIS interface. The only problem was that MPRIS needs to run on the same machine as the media player so I still needed a way to communicate between it at the OpenHAB server – that’s where MQTT comes in as I’m already using it.
I wrote this small Perl script which provides the glue between MQTT and MPRIS. I should be pretty easy to extent or adapt to other media players.
|mqtt-clementine||Perl script to interface between MQTT and MPRIS||16-01-2015|