MPD (or Music Player Daemon) is an audio player designed to run as a system service (hence the daemon), with a client-server type architecture, which starts together with the computer independently of the graphical interface. What it does is index our music library at an impressive speed and make it available to us so that we can listen to it both from the PC where it is installed, and through the network.
For this there are different clients, which are available not only for Linux, but also for Android, and even for Windows.
Despite being extremely versatile, the relative complexity of its configuration often scares off more than one person. Today I'm going to explain how to prevent MPD from running as a service and instead start it when we log in with our user's privileges. In this way we avoid an unnecessary security risk (more than one paranoid person will thank me for it ๏ ).
After following many guides and reneging more than once to configure it, I took on the task of creating a script to facilitate the configuration of this great program so that it is a little more user-friendly: here it is.
To start, we must install MPD and to control it through a graphical interface we will use Sonata:
sudo aptitude install mpd sonata
Then we stop the service and prevent it from starting as a system daemon:
sudo service mpd stop
sudo update-rc.d mpd disable
And now if we will go to the application configuration, and here I must make another clarification: the script creates a basic configuration file with the parameters just and necessary for it to work, but for the guide we will use the configuration file that MPD creates by default , which is duly commented and has many more options that may or may not be useful, so I recommend that you at least look at it.
We create the necessary directories for MPD:
mkdir -p ~ / .mpd / playlists
We copy the configuration file to the newly created folder and create the files we need:
gunzip -c /usr/share/doc/mpd/examples/mpd.conf.gz> ~ / .mpd / mpd.conf
touch ~ / .mpd / mpd.db
touch ~ / .mpd / mpd.log
touch ~ / .mpd / mpd.pid
touch ~ / .mpd / mpdstate
And now we begin to edit the configuration file itself (I use medit, you use the one you are used to):
medit ~ / .mpd / mpd.conf
First we must tell it where our music is located and the path where the files we just created are:
music_directory "~ / Music"
playlist_directory "~ / .mpd / playlists"
db_file "~ / .mpd / mpd.db"
log_file "~ / .mpd / mpd.log"
pid_file "~ / .mpd / mpd.pid"
state_file "~ / .mpd / mpdstate"
We comment on the user and group options (adding # at the beginning of the line). They are not necessary since MPD will run with the privileges of the user who starts it.
Where it says "For network" we have two options: if we are simply going to use MPD as if it were any other music player, where it says "bind_to_address" we simply put "localhost". If instead we are going to control MPD from another device (for example, an Android Smartphone, as we will explain later) or we want to stream audio, instead of localhost we will place (always in quotes) our IP address, for example:
bind_to_address "192.168.1.10"
Where it says "port" we change the one that comes by default (6600) for some other (in this case 8888) since I have read out there that the default sometimes gives problems, and it should look like this:
port ยซ8888ยป
Then I suggest you uncomment the following lines, to improve the experience (although it depends on each one):
gapless_mp3_playback "yes"
metadata_to_use ยซartist, album, title, track, name, genre, date, composer, performer, discยป
auto_update "yes"
Then we go to the audio configuration, where it says "Audio Input" we leave it as it is, and where it says "Audio Output" depending on whether we use ALSA or PulseAudio we uncomment the corresponding section. For example if we use ALSA:
audio_output {
alsa
name โMy ALSA Deviceโ}
And if we use Pulse:
audio_output {
type ยซpressยป
name "My MPD PulseAudio Output"}
If we want to listen to our music from another PC or even from our phone (as long as we are on the same local network) we can activate the http server included by default in MPD, for this we only have to uncomment the following lines:
audio_output {
type "httpd"
name "My HTTP Stream"
"vorbis" encoder # 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"
}
To connect (in theory, since this I did not have the opportunity to test it) we only have to enter the IP of our server followed by the specified port number, for example: 192.168.1.10:8000, although to play the music stream in some players we must add the following to the end "/mpd.ogg" and we would have something like this:
192.168.1.10:8000/mpd.ogg
We are almost done, I only recommend that you uncomment the following lines:
mixer_type ยซsoftwareยป #So that when adjusting the music volume it does not affect the overall volume of the system
replaygain ยซtrackยป
filesystem_charset "UTF-8"
id3v1_encoding "UTF-8"
Ready, we save the file and close the editor. Now from the console we execute "mpd" so that it starts working, and we open Sonata to configure it. We right-click anywhere in the program and choose "Preferences ..." and then MPD. There we will complete as follows:
Name: we can put what we want.
Server: Localhost or our IP (it depends on what we have put in the configuration file)
Port: 8888 (or whatever we have put in the configuration file)
and we mark the box that says "Automatically connect at startup", we click "OK" and they should be able to see their files in the "library" tab (it depends on the amount of Music they have, it may take a couple of minutes).
We can add "mpd" to the login so as not to have to start it manually every time, in XFCE we do it from: "Menu" -> "Configuration manager" -> "Session and start" -> "Auto start applications" -> "Add":
And now, I'm going to show you how you can control your music player in a very simple way from your Android, for that we only need a small application called MPDroid (I owe you the link, but you can find it in the application store).
We configure it as follows: we go to ยซSettingsยป -> ยซConnection Settingsยป -> ยซDefault Connection Settingsยป -> and there we complete it as follows:
Host: 192.168.1.10 (the address of our MPD server)
Port: 8888 (the port we assign to MPD)
Streamming host: 192.168.1.10 (the same address as our MPD server)
Streamming Port: 8000 (is the default address)
very useful and well explained
Thank you very much, I am glad that it is useful to you. Cheers!
Did you go to Ubuntu ?.
Weren't you on Crunchbang Linux?
I'm temporarily on Xubuntu (due to steam) since I had a couple of problems with Crunchbang, but I plan to return, since it is the distro in which I feel more comfortable.
When I get home, I'm going to try it, and I know it's very good
The incredible thing is the low consumption of resources that it has, that alone is worth giving it a try.
Excellent post, mpd is cool.
Thank you very much!
Ofรบ !!! :OR
Thank you very much, it was useful to me, now I can change my music sitting from the throne in the bathroom ... hahaha.
Hahaha, now I think I have achieved my goal: to simplify someone's life, I feel fulfilled ๐
Very good tutorial, before I used the automatic script that they gave in the Arch wiki, but they removed the Link and this tutorial helped me (the script did not, it marked an error).
The bad thing is that now to install a client on my Nokia E5 I need thousands of things xx
What error did the script mark you? I'm glad the tutorial was helpful to you. If you can install the client on the nokia, pass its name in case it works for someone else.
Very good! Congratulations.
Thank you!!!
Excellent ๐ MPD is king. I would just like a client like Cantata for KDE, for GTK.
Yes, the possibilities that MPD gives you are very varied. What differences does Cantata have compared to other clients? Now I am testing Ncmpcpp (from the terminal) and the truth is that it is very good and complete, it surprised me for good.
Coincidentally I was reading this: http://www.lacocina.nl/artikelen/how-to-setup-a-bit-perfect-digital-audio-streaming-client-with-free-software-with-ltsp-and-mpd
when I stumble upon your article. Does this combination seem reasonable to you?
I want to apply it but my system is LMDE KDE created by Schoejle. It is excellent and very intuitive, but like others it does not allow a bitperfect reproduction. Can what you wrote be combined in any way with what that article says? Is it necessary to do so? Thank you for your patience.
I think it should be possible, MPD is very versatile, therefore I would think that the most complicated thing would be the LTSP configuration (with which I have no experience) but as for what I put in MPD you should not have problems, The only thing I recommend is not to use the script, and read the commented configuration file to see which options are best suited to what you need.
My Spanish is not so good, but I think you mean if bitperfect playback can be combined with a local mpd installation instead of usage with LTSP?
The answer is yes. Have a look at http://lacocina.nl/audiophile-mpd to see how you can turn any computer running mpd into a bit perfect streamer.
It also contains information and scripts to automatically create a bit perfect mpd.conf, especially the audio_output {alsaโฆ} section, which is critical for bit perfect playback.
Regards,
Ronald
I get an error when trying to use MPDroid: /
Connection Failed
Connection to MPD-Server failed! Check if the Server is running and reachable. (Unable to resolve host "http://192.XXX.XXX.XXX": No address associated with hostname.)
Any idea?
How strange, did you check that MPD is working correctly on your PC? And are you connected to the same network with your phone and with your PC?
Everything works fine on my computer, the problem seems to be that it doesn't work in JellyBean 4.2
I use it on my phone with jellyBean 4.1.2 and I have no problems, it could be something else. If you can give me a link with a copy of your mpd.conf and some screenshot of the MPDroid settings maybe we can see where the problem is.
Hello good, until recently I discovered mpd and since I have tried everything and I do not know how to solve the problem I have, I have done several things that I have seen in various forums but I have not been able to solve it. The problem is the following
Failed to bind to '127.0.0.1:6600': Address already in use
I have changed the port and done other things but nothing has worked, I would appreciate your help ๐
The error appears just when typing mpd from the console, thanks ๐
If this is the ยซSIMPLEยป version, how will the difficult version beโฆ. ๐
Does anyone know how to configure to listen to music on two PCs? I mean one one I have all the music and in another I want to access that.
The script link appears to be broken, it takes me to a default template for this site.
Link to script no longer works, redirects to site root
These days I see if I can redo the script since I can't find it to re-upload it since the original was lost and I see if I can update the guide or make a new one.
everything works fine except when I browse, pressing 5 hangs and sends me the following comment MPD Stored playlists are disabled