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. So ideally, if the laptop could be used as the friendly front-end for MP3 selection, that'd be much better.

Given those two, it'd be great 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). Here's how.

STEP 1: On the Mythbox, run this command:

  esd -tcp -public -port 5001

(you may need to install the esound package first.)

STEP 2: 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.

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/remote-sound-start.sh :

#!/bin/sh
esd -tcp -public -port 5001 &
echo $! > /tmp/remote-esd.pid

/usr/local/bin/remote-sound-stop.sh :

#!/bin/sh

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

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

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

   <button>
     <type>Start Remote Sound</type>
     <text>Start Remote Sound</text>
     <action>EXEC sh /usr/local/bin/remote-sound-start.sh</action>
   </button>

   <button>
     <type>Stop Remote Sound</type>
     <text>Stop Remote Sound</text>
     <action>EXEC sh /usr/local/bin/remote-sound-stop.sh</action>
   </button>

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

~/bin/mythjuk :

#!/bin/sh
ESPEAKER=potato:5001
export ESPEAKER
exec juk

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

[GStreamerPlayer]
SinkName=esdsink

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