::::: : the wood : davidrobins.net

Discovering XBMC; connecting it to MythTV

News, Technical, Media ·Friday December 4, 2009 @ 19:10 EST (link)

Even with the 0.22 release I'm unhappy with MythTV's UI, especially for videos. Although, for example, most of my movies are found so their thumbnails show up in the selection screen, the images are tiny unless you go to the trouble of selecting one. Its TV episode lookup apparently won't find my episodes (since they're not named according to its rigid conventions). And even with the new 0.22 themes it's not as slick as one would hope with all the graphical abilities available. And it's not that configurable. For example, recently I thought I'd like to allow the user to select which movie poster image is used (rather than using the first one available on TMDB). So I went browsing for something else, and came across XBMC (originally XBox Media Center, now adapted to other systems including Linux, and renamed to the somewhat redundant "XBMC Media Center"). The graphics are very slick and it's extremely configurable, with an embedded Python (2.6) interpreter (looks like it would be easy to upgrade to 3.1 if I wanted to) that can be used for scripts or "plugins", which are sort of like virtual file systems (e.g., there is one that makes MythTV's recorded programs appear as a folder), with some useful built-in functions, including ones for windowing and dialogs.

I found a way to add a button to MythTV's "Media Library" menu to launch XBMC, but it was a little harder to determine how to give that button an icon (turns out you set the <type> to something unique, like XBMC and specify an icon for it in the theme's menu-ui.xml file; or rather, two, at least for the default Terra skin: one for when it's active (visible), and one for when it's selected. I couldn't find any images of the right size, so I grabbed one from the XBMC site, scaled it to match the other icons, and made an "active" version in Photoshop with a transparent lightning overlay, as seen here.

You are welcome to use them if you need XBMC buttons for MythTV. We'll probably still use MythTV for recording TV programs, so we need a way to go back and forth.

(Paths are for Gentoo; modify to suit.) To add the button, copy /usr/share/mythtv/themes/defaultmenu/library.xml to the .mythtv directory of the home directory of the user that MythTV runs as (usually /home/mythtv), and add the following right above the closing </mythmenu> tag:
    <button>
        <type>XBMC</type>
        <text>XBMC</text>
        <description>Launch XBMC</description>
        <action>EXEC /usr/bin/xbmc -q</action>
    </button>
(Alternatively, grab this file, but there's a risk of missing intervening updates.) As written, this will give you a button with the unsightly white on black text "No image available" (note that you'll need to leave and re-enter the menu to see the new button, but you don't need to restart MythTV). To give it an image, save the two images here as (left) xbmc_off.png and (right) xbmc_on.png in /usr/share/mythtv/themes/Terra/watermarks. To have them show up, add the following to both the end of the <state name="active"> / <statetype name="icons> and the <state name="selected" from="active"> / <statetype name="icons> blocks (i.e. after the <state name="ZM_EVENT_VIEWER" from="ZOOMFINDER"> block):
    <state name="XBMC" from="default">
        <imagetype name="icon">
            <filename>watermarks/xbmc_on.png</filename>
        </imagetype>
    </state>
Alternately (again risking missing an intervening update) you can use this file. Note that you unfortunately can't use a local version of this file as was possible with library.xml. You need to restart MythTV (exit it and depending on your setup, it should auto-restart, if not, relaunch it by restarting X, usually with startx; if you've disabled exiting, you may need to kill X with ctrl-alt-backspace; if that's disabled (as newer X.org servers do), you may need to kill X remotely. The image should now show up in Media Library, with the lightning bolt overlay when selected; clicking it will launch XBMC. Default ("confluence" skinned) XBMC can be exited by moving left to the "Power" button and selecting the red "X" (my remote "just worked" for moving and selecting; YMMV).

Next step: add MythTV as a video (and perhaps music) source. That will be fine for now, but eventually I'll want to have XBMC track videos only, so I can used its improved scripting and plugins without going through MythTV. I hope this was helpful—I didn't find anywhere else online with all the steps. No doubt I'll have more to say about XBMC as I use it: hopefully all good.

Books finished: Ayn Rand Answers, The Cat Who Walks Through Walls.