Tying it all together
- Xine video player + Unichrome XXMC driver for hardware playback
- IR receiver + LIRC daemon with Xine integration for wireless control
- 4-line LCD display + LCDProc daemon to show status information
- Backed-up DVD media available via NFS mount to backfire
Pretty much all that's left is to wire all these things together in software. The requirements for that piece of software are:
- Browse through the available media files
- Play selected media file
- Update the LCD display with title of current media file, pause/play/stop status, and position in stream
- The 'browse' and 'select' actions must be executable via the remote control
That's a pretty rough set of requirements, but it'll do for now. It took me a couple days, but I came up with a bit of software that meets these pretty nicely. It's about 1500 lines of code spead out over a dozen or so Java classes. I'm calling it '
mediabrowser' for now and you can download it here. You'll need JDK 1.5 to build it, or JRE 1.5 to run it. Both can be obtained from java.sun.com.
You'll need a recent version of Apache Ant to do the build. Just run
ant clean dist. The file
build/dist/mediabrowser.tar.gzwill be created. Extract that to your installation directory and you're ready to go.
Running Mediabrowser is fairly straightforward. Before you get started with it, ensure that the LIRC and LCDd daemons are running. Make sure that you started
-loption so it can provide the IR data over a TCP/IP port. Then follow these steps to adjust the Mediabrowser to suit your configuration:
conf/xineloader.properties. Verify that
xl.cmd.xinematches your Xine command.
mb.media.rootto match the root directory for your media collection. If you are using a remote control, change the property names for the
ir.btnmap.[...]properties to match the button names in your LIRC configuration file. That will map each button to a Java KeyEvent.
- Finally, edit the sample index file
index.xmland place it in the root media directory that you specified above. This is what the Mediabrowser will inspect to get information about your collection.
Running the Mediabrowser is as simple as
java -cp conf:bin ca.razorwire.mb.gui.MediaBrowser. A full-screen window should appear, displaying the entries in your
index.xmlfile. You can navigate the screen and select an entry using the buttons on your remote that you defined in the
How It Works
Briefly: When the GUI launches, it starts a thread to monitor for LIRC output on the default LIRC port, 8765. When it receives LIRC data that it recognizes it generates a corresponding Java AWT event indicating that a key has been typed (this is what the btnmap and keymap properties in
mb.propertiesare for). This event is sent to a hidden UI component in the GUI that always has the keyboard input focus.
As far as this UI component is concerned, a key has just been pressed. You can see this yourself by pressing any of the keys defined in the properties file. The behaviour should be exactly the same as if you'd pressed a button on the remote. It then maps the keypress to a UI action - either scrolling through the title list, scrolling the current title's description summary, or playing the title.
When you start playing a title, the GUI launches a new thread to start the Xine application as a separate process. It also stops processing LIRC output, because we don't to process any button-presses that were meant only for Xine. If the LCD screen is enabled, this thread keeps a reference to the LCD driver and the title of the current track. It monitors our hacked-up Xine output to catch the stream position updates, and prints out the track title and current position to the LCD screen. When the Xine application completes, the thread dies and control is returned to the GUI.
- Need some screenshots!
- Need a sexier GUI! Right now it's just the standard Swing look and feel. Perfectly functional, but not that attractive compared to most Media Center offerings. Maybe whip something up in OpenGL to take advantage of the hardware acceleration?
- MythTV integration... haven't got a capture card yet so I'm still quite a ways behind on the Myth scene.