Qball's Weblog
GMPC+MPD+SSH: Listen to your music from home at work
What do you need to get a nice, easy way, to play listen to your music you have at home on your work.
First we need:
- MPD running at home.
- GMPC running at your work.
- GMPC-shout plugin.
- mplayer or mpg123 to play back MPD’s stream
- Be able to setup an SSH connection to your home pc.
- Enough upload, to stream mp3/ogg.
Setting up MPD
We need to setup a httpd output.
Todo this, add this section to your mpd.conf:
1 2 3 4 5 6 7 8 9 |
audio_output { bind "127.0.0.1" type "httpd" name "streamatron" encoder "lame" format "44100:16:1" port "8000" bitrate "128" } |
This setups an output that streams your music mp3 encoded @ 128kbit, mono.
If you now start MPD, in your gmpc->server menu it should now show an extra “streamatron” output.
Note: if you don’t have an output configured and you used to let MPD autodetect, this will stop working. You need to setup an audio_output{} block for your soundcard. (see man mpd.conf).
Setting up SSH
Now we want to tell SSH to forward the right port when ssh’ing home.
So we add this little section to your ~/.ssh/config file:
1 2 3 4 |
host home hostname myhomeadress LocalForward 6600 localhost:6600 LocalForward 8000 localhost:8000 |
This assumes that you ssh to the machine running MPD, change the forward if MPD runs on another machine in your HOME network.
Now if you do:
1 |
ssh home
|
You will login to your home pc, and the right forwards are made.
Setting up GMPC
Now on your work pc, start gmpc and add a profile that connects to localhost @ port 6600.
Go to preferences->plugins enable the shout plugin, and then in Shout plugin’s preferences pane enter the following line:
1 |
mplayer -nocache http://localhost:8000/mpd.mp3 |
Or if you prefer mpg123
1 |
mpg123 http://localhost:8000/mpd.mp3 |
Screenshot:
Now if you start playback, GMPC will call mplayer or mpg123 for you, restart when it dies, and kill it when you pause or stop playback.
And that is it, if everything went ok, you should be listening to your music from home at your workplace.