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 --
#!/bin/sh esd -tcp -public -port 5001 & echo $! > /tmp/remote-esd.pid
#!/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/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:
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.
Update: Using Pulseaudio
Feb 2008: I've set up a remote-sound hack using pulseaudio and esd; details are in this blog post.
Future: Pulseaudio and RTP
http://perkypants.org/blog/2006/05/29/polypaudio-090/ - polypaudio is looking promising as of May 2006.
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:
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.