maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Multimedia (https://talk.maemo.org/forumdisplay.php?f=32)
-   -   [How-To] control MPD (music server) from your desktop (https://talk.maemo.org/showthread.php?t=51082)

shapeshifter 2010-04-26 16:00

[How-To] control MPD (music server) from your desktop
 
Here's a simple method of controlling your home desktop computer or HTPC from your n900 using the desktop command execution widget. It looks like this:

http://stuff.moritzg.ch/Screenshot-20100426-173040.png

For those who don't know what MPD is: It's the most awesome music library player around, believe me. MPD is a backend with billions of frontends for it:

General:
http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki
List of clients:
http://mpd.wikia.com/wiki/Clients

And the simplest MPD client is "mpc", a simple command line client. This is what we're gonna use for our remote control widgets. Here's the set of simple scripts used. Mind that you need to change your IP (192.168.1.2) and port (21337) to whatever your mpd server uses. Also, remember that you might have to allow clients from outside into your mpd server by commenting out 'bind_to_address "127.0.0.1"' in your mpd.conf.

repeat:
Code:

mpc -h 192.168.1.2 -p 21337 repeat | tail -n 1 | sed -e 's/vol.*repeat: //;s/random.*//'
random:
Code:

mpc -h 192.168.1.2 -p 21337 random | tail -n 1 | sed -e 's/vol.*random: //;s/single.*//
prev:
Code:

mpc -h 192.168.1.2 -p 21337 prev > /dev/null 2>&1
toggle:
Code:

mpc -h 192.168.1.2 -p 21337 toggle | sed -n 's/\\[//;s/\\].*//;2p'
next:
Code:

mpc -h 192.168.1.2 -p 21337 next > /dev/null 2>&1
playing now:
Code:

mpc -h 192.168.1.2 -p 21337 -f "%artist% - %album%: %title%" | head -n 1
If you don't want to type all this in, you can edit your ~/.desktop_cmd_exec file and edit the following things. Mind, that if you screw this up all your desktop command execution widgets will likely be broken and you'll have to start over. So you might wanna back up the file first. If you do however screw this up, don't come here whining.

Add this to the end of c_titles:
Code:

Toggle;Next;Prev;Now playing;Random;Repeat:;
Add this to the end of c_commands:
Code:

mpc -h 192.168.1.2 -p 21337 toggle | sed -n 's/\\[//\;s/\\].*//\;2p';mpc -q -h 192.168.1.2 -p 21337 next;mpc -q -h 192.168.1.2 -p 21337 prev;mpc -h 192.168.1.2 -p 21337 -f "%artist% - %album%: %title%" | head -n 1;mpc -h 192.168.1.2 -p 21337 random | tail -n 1 | sed -e 's/vol.*random: //\;s/single.*//';mpc -h 192.168.1.2 -p 21337 repeat | tail -n 1 | sed -e 's/vol.*repeat: //\;s/random.*//'
So now you can control your player from anywhere around. :)

afrinc 2010-06-05 15:42

Re: [How-To] control MPD (music server) from your desktop
 
You can use "-q" to silent output and then can remove the /dev/null redirection.


All times are GMT. The time now is 04:46.

vBulletin® Version 3.8.8