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.

Future: Polypaudio and RTP - polypaudio is looking promising as of May 2006. says (q 21):

How can I use Polypaudio to stream music from my main PC to my LAN with multiple PCs with speakers?

'On the sender side create an RTP sink:

load-module module-null-sink sink_name=rtp load-module module-rtp-send source=rtp_monitor set-default-sink rtp

This will make rtp the default sink, i.e. all applications will write to this virtual RTP device by default.

On the client sides just load the reciever module:

load-module module-rtp-recv

Now you can play your favourite music on the sender side and all clients will output it simultaneously.

BTW: You can have more than one sender machine set up like this. The audio data will be mixed on the client side.'

this will probably be the way to do it in future.

RemotePlaybackWithEsd (last edited 2008-02-03 21:37:08 by 83-71-36-102)