Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
MPD mini HOWTO
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
babo
Guru
Guru


Joined: 10 Aug 2004
Posts: 477
Location: Ljubljana

PostPosted: Thu May 05, 2005 2:02 pm    Post subject: MPD mini HOWTO Reply with quote

Since I had a lot of trouble getting mpd to work, I decided to write this. I'm no expert, but it might be usefull to someone. And corrections are wellcome ofcourse.
The user in this howto is "benjohnson"


So:

the first step is to emerge mpd and some mpd clients. I went for 'mpc' (command line) and 'kmp' which is not masked for amd64 and x86 (this are the archs I have)

Code:
# emerge mpd mpc kmp


than configuration comes in:

/etc/mpd.conf
Code:
# MPD CONFIG FILE
# For a full description of all config parameters,
# Check the mpd man page, "man mpd".

##################### REQUIRED ###########################
port "6600"
music_directory "/your/music/directory"
playlist_directory "/usr/share/mpd/playlists"
log_file "/usr/share/mpd/mpd.log"
error_file "/usr/share/mpd/mpd.error.log"
##########################################################

##########################################################
# EVERYTHING ELSE IS OPTIONAL
##########################################################

################# FILESYSTEM SETTINGS ####################
#
# If the names of files or directories are
# not correctly displayed then set the
# following to the filesystem coding.
#
#       Usually this is either:
#       ISO-8859-1 or UTF-8
#
# After changing the filesystem_charset
# you will need to recreate the db:
#       mpd --create-db
#
filesystem_charset "UTF-8"
#
##########################################################

#################### OPTIONAL FILES ######################
#
# Location of DB file
#
db_file         "/usr/share/mpd/mpd.db"
#
# The state file (if set) will be a file
# for storing all current information
# (playlist, playing/paused, etc...) from
# the last MPD session. This will be used
# to recreate your last MPD session after
# restart.
#
state_file              "~/.mpd/mpdstate"
#
##########################################################


################### VOLUME MIXER #########################
#
# Examples:
# ALSA Mixer
mixer_type              "alsa"
mixer_device            "default"
mixer_control           "PCM"
#
# OSS Mixer
#mixer_type             "oss"
#mixer_device           "/dev/mixer"
#mixer_control          "PCM"
#
# Software Mixer
#mixer_type             "software"
#
##########################################################


################## AUDIO OUTPUT ##########################
#
# OSS Audio Output
#ao_driver              "oss"
#ao_driver_options      "dsp=/dev/dsp"
#
# ALSA Audio Output
ao_driver               "alsa09"
ao_driver_options       "dev=hw:0,0"
#
# Set this if you have problems
# playing audio files.
# This will resample your music so
# that it comes out at the set rate.
#
audio_output_format     "44100:16:2"
#
# You should not need mess with
# this value unless you know
# what you're doing.
#
#audio_write_size       "1024"
#
##########################################################

################# REPLAYGAIN #############################
#
# Use Replay Gain (album or title)
#       http://www.replaygain.org
#
#replaygain             "album"
#
# Sets the pre-amp used for files that have replaygain
# info.  Valid values are between -15 to 15 (in dB).
#
#replaygain_preamp      "0"
#
##########################################################


################ OUTPUT BUFFER SETTINGS ##################
#
# You should not need to mess with this
# unless you know what you're doing.
#
#audio_buffer_size      "2048"
#
# This means exactly what it says, it will
# buffer your file up to the percentage of
# the buffer before it begins playing.
#
#buffer_before_play     "25%"
#
##########################################################


################### HTTP PROXY ###########################
#
# http_proxy_host       "proxy.isp.com"
# http_proxy_port       "8080"
# http_proxy_user       "user"
# http_proxy_password   "password"
#
##########################################################


################# SECURITY SETTINGS ######################
#
# It is encouraged to run MPD as
# non-superuser.  If you start mpd as root
# (for example, in an init script), set
# this value, then  mpd will drop root priveleges
# and runs as the user specified.
#
user "benjohnson"
#
# Set this value if you only have one
# address you want to allow connection to.
#
bind_to_address "localhost"
#
# If you want to setup MPD to use
# passwords set them here
#
#password               "password1@read,add,control,admin"
#password               "password2@read"
#
# Specify permissions used by default when no password is
# given by for a connection/client.
#
#default_permissions    "read,add,control,admin"
#
##########################################


################ MISCELLANEOUS OPTIONS ###################
#
# This setting exists as precaution against attacks.
#
#max_playlist_length    "16384"
#
# Valid options are "default", "secure" or "verbose".
#log_level              "default"
#
#connection_timeout     "60"
#
# This should be fine for 2-3 people using clients
# at the same time.
#
#max_connections        "5"
#
# No need to change these unless you know better.
#
#max_command_list_size  "2048"
#max_output_buffer_size "2048"
#
# This will make playlists compatible with normal music
# players.
#
#save_absolute_paths_in_playlists "no"
#
##########################################################


This is obviously a conf file for alsa users, I guess it should work for oss users if you comment the alsa lines and uncomment the oss ones.
I don't remember if I had to make mpd folder in /usr/share but I know I had to chmod it, so:

Code:
# mkdir /usr/share/mpd
# chmod -R 777 /usr/share/mpd


In /etc/group you have to add user mpd to audio

Code:
audio::18:benjohnson,mpd


and than I figured out from praseworthy gentoo forums I have to change a line in /etc/passwd and /etc/security/console.perms , so don't ask me too much about this two. There are probably other workarounds.

in /etc/passwd the last line should be about mpd, change it to:
Code:
mpd:x:104:18:added by portage for mpd:/usr/share/mpd/:/bin/false


and you should also change a line in /etc/security/console.perms from:
Code:
<console>  0600 <sound>      0600 root.audio

to:
Code:
<console>  0660 <sound>      0660 root.audio


(change two zero's to six's)

the legend says that this last one is a solution to a gentoo specific problem.

after this you should do:
Code:
# mpd --create-db


and if all is ok this should work:
Code:
# /etc/init.d/mpd start


and than you can add mpd to default runlevel:
Code:
# rc-update add mpd default


now mpd should work :), but we all know how this things go :)

Next phase is enjoying the fruits of our hard labor:
(as said before I use kmp, but all the clients are basicly the same in my eyes)
Code:
$ kmp


if it is not allready connected you go to --> file --> connect and write "localhost" in host textwindow and "6600" as port and I also like having Auto-Connect checked.

Now you should be able to restart your desktop and still have your music playing :)) and probably some other usefull stuff to.

Hope this is all you need to do and that it works.
Back to top
View user's profile Send private message
killfire
l33t
l33t


Joined: 04 Oct 2003
Posts: 618

PostPosted: Wed May 11, 2005 5:08 pm    Post subject: Reply with quote

just tried it (followed all the directions) and im sorry to say it doesnt work on my machine..

the song highlights for a second (or bolds) and then loses focus...

nothing will play...


as in, the server will start, the client will start, i can add songs to the playlist, but it wont actually play...

i use alsa..

killfire

[edit]

the way i got it to work is not using a config file...

if i start it like this:
Code:

mpd 6600 /path/to/music /path/to/playlists /var/log/mpd.log /var/log/mpd.error.log


it works... (and it works without the /etc/security changes)
weird
_________________
my website, built in HAppS: http://dbpatterson.com
an art (oil painting) website I built a pure python backend for: http://www.lydiajohnston.com
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Wed May 11, 2005 5:37 pm    Post subject: Reply with quote

I'm kind of sruprised that people had a hard time getting it working, but I guess everyone's setup is different. The main things to keep track of are who it runs as, the permissions of all the referenced files, and the right directory for the music.

by the way, try mpd-svn, the development version. It has a few more features (like databsing the ID3 tags ,etc), and is sitll backwards compat with the older one. Of course, the clients won't know about the new features yet, but you can either throw together some shell scripts with netcat, or write your own pygtk GUI interface like I did. :)

Also, ncmpd is a great cmdline player for it.
Back to top
View user's profile Send private message
bertaboy
l33t
l33t


Joined: 05 Nov 2004
Posts: 604

PostPosted: Thu May 19, 2005 3:01 am    Post subject: Reply with quote

I guess it wasn't so simple for me to set up. At first, /usr/bin/mpd --create-db was complaining about not being able to modify the .db file, so I hunted it down, finding out it had yet to be created. So I ended up touching it, then I got the same error message. Permissions problems, which was easily solved by chmodding it 777 (probably not the safest thing to do, but I don't really know how much of a security concern the .db file is....) Then it had the same error message, but complaining about the log files. chmod 666 /var/log/mpd* solved that problem. After that, /usr/bin/mpd --create-db worked, and now I have mpd up and running.
Back to top
View user's profile Send private message
babo
Guru
Guru


Joined: 10 Aug 2004
Posts: 477
Location: Ljubljana

PostPosted: Thu May 19, 2005 10:12 am    Post subject: Reply with quote

Compared to lets say xmms it was like a PhD to set it up for me. Are there any things to be changed in instructions?
Back to top
View user's profile Send private message
killfire
l33t
l33t


Joined: 04 Oct 2003
Posts: 618

PostPosted: Thu May 19, 2005 7:50 pm    Post subject: Reply with quote

babo wrote:
Compared to lets say xmms it was like a PhD to set it up for me. Are there any things to be changed in instructions?



well, for me, they just plain didnt work.
_________________
my website, built in HAppS: http://dbpatterson.com
an art (oil painting) website I built a pure python backend for: http://www.lydiajohnston.com
Back to top
View user's profile Send private message
ikaro
Advocate
Advocate


Joined: 14 Jul 2003
Posts: 2527
Location: Denmark

PostPosted: Thu May 19, 2005 9:35 pm    Post subject: Reply with quote

you are just complicating things :)


Code:

music_directory      "/home/ftp/music"
playlist_directory   "/home/ftp/music/.mpd/playlist"
db_file       "/home/ftp/music/.mpd/mpd.db"
log_file      "/home/ftp/music/.mpd/mpd.log"
error_file      "/home/ftp/music/.mpd/mpd.error.log"
pid_file      "/var/run/mpd/mpd.pid"
state_file      "/home/ftp/music/.mpd/mpdstate"
filesystem_charset "ISO-8859-1"
user "mpd"
bind_to_address "localhost"
################## AUDIO OUTPUT ##########################

audio_output {
   type      "alsa"
   name      "ALSA"
   device      "hw:0,0"
   format      "48000:16:2"
}
audio_output_format   "48000:16:2"

################### VOLUME MIXER #########################

mixer_type      "alsa"
mixer_device      "dmixer"
mixer_control      "PCM"

##########################################################


Chown the dirs/files that mpd will access with: mpd:audio
add our user account to the audio group.

Thats all there is to it, and everything should work :)
_________________
linux: #232767
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum