lastfmproxy is a python script that streams a last.fm music stream to another media player. To setup, install from AUR: {{Ic|yaourt -S lastfmproxy}} and then edit {{Filename|/usr/share/lastfmproxy/config.py}}. If you plan to only stream to mpd on the same host, just edit the login info.

{{Note | Since it installs to a read only directory but it requires read/write access for features like saving previously listened to stations, it would be wise to copy {{Filename|/usr/share/lastfmproxy}} to your home directory.}}

+

{{hc|/etc/mpd.conf|2=

+

playlist_plugin {

+

name "lastfm"

+

user "my_username"

+

password "my_password"

+

}

+

}}

−

Start lastfmproxy with {{Ic|lastfmproxy}} and visit http://localhost:1881/ in your web browser. To add a last.fm station navigate to http://localhost:1881/ followed by the lastfm:// url. Example: http://localhost:1881/lastfm://globaltags/punk . Navigate back to http://localhost:1881/ and download the m3u file by selecting the ''Start Listening'' link. Simply add it to your music library path.

If you do not want mpd to always play on your system start, but yet you want to preserve the other state information, add the following lines to your {{Filename|/etc/rc.d/mpd}} file:

+

This feature has recently been added to mpd git by Martin Kellerman, see commits {{ic|b57330cf75bcb339e3f268f1019c63e40d305145}} and {{ic|2fb40fe728ac07574808c40034fc0f3d2254d49d}}. As of September 2011, this feature has not yet arrived in a mpd version in the official repositories. If support for this feature is still required, have a look at the following proposals.

+

+

====Installing mpd from the AUR====

+

This is the best method currently available, but is only currently (as of April 2011) enabled in the git version. Install {{AUR|mpd-git}} from the [[AUR]] and add {{ic|restore_paused "yes"}} to your {{ic|mpd.conf}} file.

+

+

If you have issues with connecting your client to {{AUR|mpd-git}}, see [[Music Player Daemon#Other issues when attempting to connect to mpd with a client]].

+

+

====Method 1====

+

If you do not want MPD to always play on your system start, but yet you want to preserve the other state information, add the following lines to your {{ic|/etc/rc.d/mpd}} file:

+

=====Method 1.1=====

+

Simpler, working method (disables playing on startup of mpd daemon):

+

start)

+

...

+

mpc -q pause #add this line only

+

add_daemon mpd

+

stat_done

+

=====Method 1.2=====

+

This method was described here before Method 1.1 and is much more complicated:

'' ...''

'' ...''

'' stat_busy "Starting Music Player Daemon"''

'' stat_busy "Starting Music Player Daemon"''

Line 179:

Line 222:

'' ...''

'' ...''

−

This will change the player status to "paused", if it was stopped while playing. Next, you want this file to be preserved, so mpd updates won't erase this edit. Add (or edit) this line to your {{Filename|/etc/pacman.conf}}:

+

This will change the player status to "paused", if it was stopped while playing. Next, you want this file to be preserved, so MPD updates won't erase this edit. Add (or edit) this line to your {{ic|/etc/pacman.conf}}:

NoUpgrade = etc/rc.d/mpd

NoUpgrade = etc/rc.d/mpd

−

Or Simple method add mpd to your rc.conf daemons array and add mpc stop to rc.local loacated in /etc (Remember you must got mpc installed to have this method working).

−

===MPD & Alsa===

+

====Method 2====

+

Another simpler method, would be to add mpd to your {{ic|[[rc.conf]]}} daemons array and add {{ic|mpc stop}} or {{ic|mpc pause}} to {{ic|/etc/rc.local.shutdown}} and to {{ic|/etc/rc.local}}. (Remember you must have mpc installed to use this method).

Adding only the order in {{ic|/etc/rc.local}} cannot assure that mpd will play absolutely nothing, since there may be a delay before the stop command is executed.

+

On the other hand, if you only add the order to {{ic|/etc/rc.local.shutdown}}, that will assure that mpd won't play at all, as long as you properly shutdown your system.

+

Even though they are redundant, adding it to {{ic|/etc/rc.local}} would serve as a safety for those, presumably, rare occasions when you do not shutdown the system properly.

−

Error opening alsa device "hw:0,0": Device or resource busy

+

====Method 3====

+

The general idea is to ask mdp to pause music when the user logs out, so that mdp will stick to the "pause" state after a reboot. Sending such command can be achieved using [https://www.archlinux.org/packages/extra/x86_64/mpc/ mpc], the command line interface to MPD.

−

And here is the solution (dmix saving our life again). Apply these lines in your {{Filename|/etc/mpd.conf}}:

+

GDM users can then add {{ic|/usr/bin/mpc pause}} to {{ic|/etc/gdm/PostSession/Default}} (be sure to add it before {{ic|exit 0}}):

−

<pre>

+

Non-GDM users can use their own login manager's method to launch the line at logout.

When using MPD with ALSA, users may experience MPD taking up lots of CPU (around 20-30%). This is caused by most sound cards supporting 48kHz and most music being 44kHz, thus forcing MPD to resample it. This operation takes lots of CPU cycles and results into high usage.

−

For most users the problem should be solved by telling MPD not to use resampling by adding {{Ic|auto_resample "no"}} into audio_output-part of {{Filename|/etc/mpd.conf}}.

Some users might also want to tell dmix to use 44kHz as well. More info about tuning performance of your MPD can be found from: [http://mpd.wikia.com/wiki/Tuning MPD wiki]

+

{{hc|

+

/etc/asound.conf|

+

defaults.pcm.dmix.rate 44100 # Force 44.1 KHz

+

defaults.pcm.dmix.format S16_LE # Force 16 bits

+

}}

−

===Control mpd with lirc===

+

{{hc|

−

There are already some clients designe for communications between lircd and mpd, however, as far as the practical use, they aren't very useful since their functions are limited.

+

/etc/mpd.conf|2=

+

audio_output {

+

type "alsa" # Use the ALSA output plugin.

+

name "HDA Intel" # Can be called anything or nothing tmk, but must be present.

+

options "dev=dmixer"

+

device "plug:dmix" # Both lines cause MPD to output to dmix.

+

format "44100:16:2" # the actual format

+

auto_resample "no" # This bypasses ALSA's own algorithms, which generally are inferior. See below how to choose a different one.

+

use_mmap "yes" # Minor speed improvement, should work with all modern cards.

+

}

−

It's recommended to use mpc with irexec. mpc is a command line player which only sends the command to mpd and exits immediately, which is perfect for irexec, the command runner included in lirc. What irexec does is that it runs a specified command once received a remote control button.

+

samplerate_converter "0" # MPD's best, most CPU intensive algorithm. See 'man mpd.conf' for others — for anything other than the poorest "internal", libsamplerate must be installed.

+

}}

−

First of all, please setup your remotes as referred to the '''[[Lirc]]''' article.

First, install ([http://aur.archlinux.org/packages.php?ID=18722 mpd-pulse]) in the Arch User Repository as opposed to the regular mpd client in the Extra repository.

+

Un ejemplo útil:

−

Then, edit {{Filename|/etc/mpd.conf}}, and uncomment the audio_output section for the type "pulse". The server and sink lines of it should be commented unless you know what you're doing.

+

{{hc|

+

~/.lircrc| 2=

+

## irexec

+

begin

+

prog = irexec

+

button = play_pause

+

config = mpc toggle

+

repeat = 0

+

end

−

Then, add the mpd user (and yours if you haven't done so already) to the necessary pulse groups. The pulse-access group should be sufficient but you may want to add pulse-rt as well. The group "pulse" doesn't appear to be necessary.

+

begin

−

# gpasswd -a mpd pulse-access

+

prog = irexec

−

# gpasswd -a mpd pulse-rt

+

button = stop

+

config = mpc stop

+

repeat = 0

+

end

+

begin

+

prog = irexec

+

button = previous

+

config = mpc prev

+

repeat = 0

+

end

+

begin

+

prog = irexec

+

button = next

+

config = mpc next

+

repeat = 0

+

end

+

begin

+

prog = irexec

+

button = volup

+

config = mpc volume +2

+

repeat = 1

+

end

+

begin

+

prog = irexec

+

button = voldown

+

config = mpc volume -2

+

repeat = 1

+

end

+

begin

+

prog = irexec

+

button = pbc

+

config = mpc random

+

repeat = 0

+

end

+

begin

+

prog = irexec

+

button = pdvd

+

config = mpc update

+

repeat = 0

+

end

+

begin

+

prog = irexec

+

button = right

+

config = mpc seek +00:00:05

+

repeat = 0

+

end

+

begin

+

prog = irexec

+

button = left

+

config = mpc seek -00:00:05

+

repeat = 0

+

end

+

begin

+

prog = irexec

+

button = up

+

config = mpc seek +1%

+

repeat = 0

+

end

+

begin

+

prog = irexec

+

button = down

+

config = mpc seek -1%

+

repeat = 0

+

end

+

}}

−

Lastly, you may or may not need to copy {{Filename|~/.pulse-cookie}} from your current (pulse working) user's dir to your mpd user's home directory. It is likely to be {{Filename|/var/lib/mpd}} if you followed the first part of this wiki. This would probably only allow your current user to listen in on mpd's pulse. You may consider running pulse system-wide if that's insufficient.

If you want to use another computer to control mpd over a network, the {{Ic|bind_to_address}} option in {{Filename|mpd.conf}} will need to be set to either your IP address, or {{Ic|any}} if your IP address changes frequently. Remember to add mpd to the {{Filename|/etc/hosts.allow}} file to enable external access.

Since version 0.15 there is a built-in HTTP streaming daemon/server that comes with MPD. To activate this server simply set it as output device in mpd.conf:

−

name "What you want"

−

encoder "lame" # vorbis or lame supported

−

port "8000"

−

bitrate "128"

−

format "44100:16:2" # change 2 to 1 for mono

−

}

−

−

Restart the mpd daemon and, from another computer, simply load the stream as any other url.

−

mplayer http://<server's IP>:8000

+

audio_output {

+

type "httpd"

+

name "My HTTP Stream"

+

encoder "vorbis" # optional, vorbis or lame

+

port "8000"

+

# quality "5.0" # do not define if bitrate is defined

+

bitrate "128" # do not define if quality is defined

+

format "44100:16:1"

+

}

−

Most players (i.e. vlc or xmms2) should also be able to load the stream via their "add url..." menu option.

+

Then to listen to this stream simply open the URL of your mpd server (along with the specified port) in your favorite music player. Note: You may have to specify the file format of the stream using an appropriate file extension in the URL. For example, using Winamp 5.5, You would use http://192.168.1.2:8000/mpd.ogg rather than http://192.168.1.2:8000/.

−

This is a nice clean way to replace your current icecast setup with something natively supported within MPD.

If files and/or titles are shown in wrong encoding, uncomment and change {{ic|filesystem_charset}} and {{ic|id3v1_encoding}} options.

−

# chsh -s /bin/true mpd

+

Note that you cannot set encoding for ID3 v2 tags. To workaround this you may use [http://mpd.wikia.com/wiki/GenericDecoder#Generic_Tagreader external tag readers].

+

+

If you want to use another computer to control MPD over a network, the {{ic|bind_to_address}} option in {{ic|mpd.conf}} will need to be set to either your IP address, or {{ic|any}} if your IP address changes frequently.

+

+

'''Streaming'''<br>

+

With the latest version of MPD (0.15), built-in httpd streaming is now available.

−

===Permisos de archivos y directorios===

+

To activate this feature, you'll just need to add a new output of type httpd in {{ic|mpd.conf}}:

−

{{Warning|Estas direcciones se prestan a problemas de seguridad.}}

+

audio_output {

+

type "httpd"

+

name "What you want"

+

encoder "lame" # vorbis or lame supported

+

port "8000"

+

bitrate "128"

+

format "44100:16:2" # change 2 to 1 for mono

+

}

+

+

Restart the mpd daemon and, from another computer, simply load the stream as any other url.

===Cannot connect to mpd: host "localhost" not found: Temporary failure in name resolution===

===Cannot connect to mpd: host "localhost" not found: Temporary failure in name resolution===

−

Cannot connect to mpd (with ncmpcpp), if you are disconnected from network. Solution is [[IPv6 - Disabling the Module|disable IPv6]] or add line to /etc/hosts

+

Cannot connect to MPD (with ncmpcpp), if you are disconnected from network. Solution is [[IPv6 - Disabling the Module|disable IPv6]] or add line to /etc/hosts

−

::1 localhost.localdomain localhost

::1 localhost.localdomain localhost

−

===Port 6600 already in use===

+

===Other issues when attempting to connect to mpd with a client===

−

MPD needs to bind to port 6600 and cannot start if it's already in use. The most common reason for this is that the user has started mpd once and then subsequently tried mpd --create-db. New mpd behavior is the --create-db option also attempts to start the daemon; if it's already been started, this will fail. If this is the case, try the following:

+

Some have reported being unable to access mpd with various clients, for example seeing errors like these:

+

$ ncmpcpp

+

Cannot connect to mpd: Connection closed by the server

+

$ sonata

+

2011-02-13 18:33:05 Connection lost while reading MPD hello

+

2011-02-13 18:33:05 Not connected

+

2011-02-13 18:33:05 Not connected

−

$ mpd --kill

+

Please see posts on ncmpcpp on the Arch Forums [https://bbs.archlinux.org/viewtopic.php?id=109962 HERE] and [https://bbs.archlinux.org/viewtopic.php?id=113493 HERE]. Also see the Arch bug report on this issue [https://bugs.archlinux.org/task/22071 HERE].

−

$ mpd --create-db

−

A more brute-force approach:

+

====First fix====

+

Check {{ic|mpd.conf}} for a line like {{ic|mpd.error}} and remove it. The mpd error file is deprecated and has been removed.

−

$ killall mpd

+

====Second fix====

−

$ mpd --create-db

+

{{Note|I'm not so sure this is a good idea. There is a warning about changing the address to bind to in the default mpd.conf. If this does not help, you might want to comment out the changes.}}

+

If that doesn't help, add the following to {{ic|mpd.conf}}:

+

{{bc|

+

bind_to_address "127.0.0.1"

+

port "6600"

+

}}

−

{{Note| If you typically run mpd as root, you will need to run the above commands as root.}}

+

Afterwards, instruct your client to connect via 127.0.0.1. For example, add the following to the ncmpcpp config file:

+

{{bc|

+

mpd_host "127.0.0.1"

+

mpd_port "6600"

+

}}

−

In the git version of mpd, --create-db is completely deprecated. The database will be created automagically on first run and can subsequently be updated via your client (i.e. mpc update). Eventually, inotify support will offer fully automatic database updates as you add content to your music folders

+

===Port 6600 already in use===

+

MPD needs to bind to port 6600 and cannot start if it's already in use. The most common reason for this is that the user has started MPD once and then subsequently tried to start mpd again. In general, nothing should be done here.

If port 6600 is tied up for some other reason, one can use the following command to find the offending process:

If port 6600 is tied up for some other reason, one can use the following command to find the offending process:

+

# ss -tulpan | grep 6600

−

# netstat -tulpan | grep 6600

+

This will list IP:Port and the process name holding the connection (root privileges are required to see all processes).

−

This will list IP:Port and the process name holding the connection (root privileges are required to see all processes).

+

If you need to restart mpd for whatever reason, use:

+

{{bc|

+

$ mpd --kill

+

$ mpd

+

}}

+

A more brute-force approach:

+

{{bc|

+

$ killall mpd

+

$ mpd

+

}}

+

{{Note| If you typically run MPD as root, you will need to run the above commands as root.}}

+

+

In the latest version of MPD, --create-db is completely deprecated. The database will be created automagically on first run and can subsequently be updated via your client (i.e. mpc update). You can now use inotify support to automatically update your music database. Add the following to {{hc|mpd.conf|auto_update "yes"}} to enable it.

+

+

===Binding to IPV6 before IPV4===

+

If on startup, you see this message:

+

listen: bind to '0.0.0.0:6600' failed: Address already in use (continuing anyway, because binding to '[::]:6600' succeeded)

+

MPD is attempting to bind to the ipv6 interface before binding to ipv4. If you want to use your ipv4 interface, hardcode it in mpd.conf, like so:

+

bind_to_address "127.0.0.1"

+

Or, you could specify several binds, for example, to have MPD listen on localhost and the external IP of your network card:

+

bind_to_address "127.0.0.1"

+

bind_to_address "192.168.1.13"

===Crackling sound with some audio files===

===Crackling sound with some audio files===

−

This is usually a playback speed problem and can be fixed by uncommenting the audio_output_format line in:

This is usually a playback speed problem and can be fixed by uncommenting the audio_output_format line in:

−

{{File|name=/etc/mpd.conf|content=

+

{{hc|/etc/mpd.conf|

audio_output_format "44100:16:2"}}

audio_output_format "44100:16:2"}}

This is usually a sane value for most mp3 files.

This is usually a sane value for most mp3 files.

−

==Enlaces Externos==

+

===daemon: cannot setgid for user "mpd": Operation not permitted ===

+

+

The error is stating that the user starting the process (you) does not have permissions to become another user (mpd) which the configuration has told that process to run as.

+

+

To solve the issue, simply start mpd as root.

+

{{bc|$ su -c "rc.d start mpd"}}

+

or

+

{{bc|# rc.d start mpd}}

−

* [http://www.musicpd.org/ Web site Oficial]

+

==External links==

−

* [http://mpd.wikia.com/wiki/Main_Page Wiki Oficial]

+

* [http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki Official Web Site and wiki]

Never play on start

This feature has recently been added to mpd git by Martin Kellerman, see commits b57330cf75bcb339e3f268f1019c63e40d305145 and 2fb40fe728ac07574808c40034fc0f3d2254d49d. As of September 2011, this feature has not yet arrived in a mpd version in the official repositories. If support for this feature is still required, have a look at the following proposals.

Installing mpd from the AUR

This is the best method currently available, but is only currently (as of April 2011) enabled in the git version. Install mpd-gitAUR from the AUR and add restore_paused "yes" to your mpd.conf file.

This will change the player status to "paused", if it was stopped while playing. Next, you want this file to be preserved, so MPD updates won't erase this edit. Add (or edit) this line to your /etc/pacman.conf:

NoUpgrade = etc/rc.d/mpd

Method 2

Another simpler method, would be to add mpd to your rc.conf daemons array and add mpc stop or mpc pause to /etc/rc.local.shutdown and to /etc/rc.local. (Remember you must have mpc installed to use this method).

Adding only the order in /etc/rc.local cannot assure that mpd will play absolutely nothing, since there may be a delay before the stop command is executed.
On the other hand, if you only add the order to /etc/rc.local.shutdown, that will assure that mpd won't play at all, as long as you properly shutdown your system.
Even though they are redundant, adding it to /etc/rc.local would serve as a safety for those, presumably, rare occasions when you do not shutdown the system properly.

Method 3

The general idea is to ask mdp to pause music when the user logs out, so that mdp will stick to the "pause" state after a reboot. Sending such command can be achieved using mpc, the command line interface to MPD.

GDM users can then add /usr/bin/mpc pause to /etc/gdm/PostSession/Default (be sure to add it before exit 0):

Non-GDM users can use their own login manager's method to launch the line at logout.

audio_output {
type "alsa" # Use the ALSA output plugin.
name "HDA Intel" # Can be called anything or nothing tmk, but must be present.
options "dev=dmixer"
device "plug:dmix" # Both lines cause MPD to output to dmix.
format "44100:16:2" # the actual format
auto_resample "no" # This bypasses ALSA's own algorithms, which generally are inferior. See below how to choose a different one.
use_mmap "yes" # Minor speed improvement, should work with all modern cards.
}
samplerate_converter "0" # MPD's best, most CPU intensive algorithm. See 'man mpd.conf' for others — for anything other than the poorest "internal", libsamplerate must be installed.

Then to listen to this stream simply open the URL of your mpd server (along with the specified port) in your favorite music player. Note: You may have to specify the file format of the stream using an appropriate file extension in the URL. For example, using Winamp 5.5, You would use http://192.168.1.2:8000/mpd.ogg rather than http://192.168.1.2:8000/.

Note: in case of permission problems when using ESD with MPD run this as root:

# chsh -s /bin/true mpd

Avoiding timeouts

To get rid of timeouts (i.e. when you paused music for long time) in gpmc and other clients uncomment and increase connection_timeout option in mpd.conf.

If files and/or titles are shown in wrong encoding, uncomment and change filesystem_charset and id3v1_encoding options.
Note that you cannot set encoding for ID3 v2 tags. To workaround this you may use external tag readers.

If you want to use another computer to control MPD over a network, the bind_to_address option in mpd.conf will need to be set to either your IP address, or any if your IP address changes frequently.

Streaming
With the latest version of MPD (0.15), built-in httpd streaming is now available.

To activate this feature, you'll just need to add a new output of type httpd in mpd.conf:

Please see posts on ncmpcpp on the Arch Forums HERE and HERE. Also see the Arch bug report on this issue HERE.

First fix

Check mpd.conf for a line like mpd.error and remove it. The mpd error file is deprecated and has been removed.

Second fix

Note: I'm not so sure this is a good idea. There is a warning about changing the address to bind to in the default mpd.conf. If this does not help, you might want to comment out the changes.

If that doesn't help, add the following to mpd.conf:

bind_to_address "127.0.0.1"
port "6600"

Afterwards, instruct your client to connect via 127.0.0.1. For example, add the following to the ncmpcpp config file:

mpd_host "127.0.0.1"
mpd_port "6600"

Port 6600 already in use

MPD needs to bind to port 6600 and cannot start if it's already in use. The most common reason for this is that the user has started MPD once and then subsequently tried to start mpd again. In general, nothing should be done here.

If port 6600 is tied up for some other reason, one can use the following command to find the offending process:

# ss -tulpan | grep 6600

This will list IP:Port and the process name holding the connection (root privileges are required to see all processes).

If you need to restart mpd for whatever reason, use:

$ mpd --kill
$ mpd

A more brute-force approach:

$ killall mpd
$ mpd

Note: If you typically run MPD as root, you will need to run the above commands as root.

In the latest version of MPD, --create-db is completely deprecated. The database will be created automagically on first run and can subsequently be updated via your client (i.e. mpc update). You can now use inotify support to automatically update your music database. Add the following to

mpd.conf

auto_update "yes"

to enable it.

Binding to IPV6 before IPV4

If on startup, you see this message:

listen: bind to '0.0.0.0:6600' failed: Address already in use (continuing anyway, because binding to '[::]:6600' succeeded)

MPD is attempting to bind to the ipv6 interface before binding to ipv4. If you want to use your ipv4 interface, hardcode it in mpd.conf, like so:

bind_to_address "127.0.0.1"

Or, you could specify several binds, for example, to have MPD listen on localhost and the external IP of your network card:

bind_to_address "127.0.0.1"
bind_to_address "192.168.1.13"

Crackling sound with some audio files

This is usually a playback speed problem and can be fixed by uncommenting the audio_output_format line in:

/etc/mpd.conf

audio_output_format "44100:16:2"

This is usually a sane value for most mp3 files.

daemon: cannot setgid for user "mpd": Operation not permitted

The error is stating that the user starting the process (you) does not have permissions to become another user (mpd) which the configuration has told that process to run as.