Remote Playback With esd

I have a laptop which contains my 30 gigabytes or so of music collection. I also have a networked MythTV box hooked into the main AV equipment, with nice speakers etc.; however, dealing with playlists with a remote control and a TV as the UI is awful (I've tried). The laptop rules for playlist manipulation and control.

Obviously, I could hook the laptop up to the speakers directly, switching cables and all that, but that's what I want to avoid.

So, the target was to have a way to select and cue playlists on the laptop, with the sound coming via the Mythbox.

It turns out this is stunningly easy with the venerable esd (the Enlightenment Sound Daemon), which [ supports network playback]. Here's how.

On the Mythbox, install the esound package and run this command:

  esd -tcp -public -port 5001

On the laptop, run this command:

  export ESPEAKER=mythbox:5001
  mpg321 -o esd /path/to/file.mp3

Sure enough, the sound comes from the Mythbox! Any app that supports esd as a method of sound output -- JuK, Rhythmbox, mpg321, xmms, the Flash plugin, etc. -- can be run in place of mpg321. As long as that picks up the ESPEAKER environment variable, you're laughing.

It appears the sound stream is plain old TCP/IP, running at about 200 KiB/second. That should be fine, even on a lossy wifi network like the one I'm using.

You should probably ensure that the network in question is protected by a firewall, to avoid people playing noise through your TV. duh.

Giving this a UI

I threw together a few rudimentary scripts to make this usable. Here they are.

First off, the changes made on the Mythbox itself --

/usr/local/bin/ :

esd -tcp -public -port 5001 &
echo $! > /tmp/

/usr/local/bin/ :


pid=`cat /tmp/`
if [ "$pid" -lt 3 ] ; then
  ( echo "Server was not running." | festival --tts ) &

  kill $pid
  rm $pid
  ( echo "Server stopped." | festival --tts ) &

These lines were added to the end of /usr/share/mythtv/mainmenu.xml , just before the </mythmenu> line:

     <type>Start Remote Sound</type>
     <text>Start Remote Sound</text>
     <action>EXEC sh /usr/local/bin/</action>

     <type>Stop Remote Sound</type>
     <text>Stop Remote Sound</text>
     <action>EXEC sh /usr/local/bin/</action>

And I wrote this script to run JuK, the excellent KDE music player application, with playback through the Mythbox:

~/bin/mythjuk :

exec juk

Correspondingly, ~/.kde/share/config/jukrc has these lines added to the end so that it'll always play via esd:


So now, when I want to play music through the TV from my laptop, I hit the 'Start Remote Server' button on myth, fire up 'mythjuk' on the laptop, and I'm off.