I am trying to add a local file to mpd ( through mpc ) and play it . my platform is OpenWRT embedded linux .
so, from the man page, it states:
mpc add <file> Add a song to the current playlist
if i do:
root@OpenWrt:~/.mpd# mpc add /usr/share/baresip/ring.wav
error adding /usr/share/baresip/ring.wav: directory or file not found
or if i do:
root@OpenWrt:~/.mpd# mpc add file:///usr/share/baresip/ring.wav
error adding file:///usr/share/baresip/ring.wav: Access denied
what exactly is the correct syntax here? the man page is really not very clear for mpc / mpd .
Your second attempt was almost right. The problem you had was that mpd
will only allow file:
URLs to be passed to it via a local connection, which it enforces by requiring you to connect on its unix-domain socket. So, in your mpd.conf
you need to have a line like this:
bind_to_address "/run/mpd/socket"
(depending on your system you may want to change /run
to /var/run
-- the version I quote is correct for recent versions of debian or ubuntu but others may be different).
Then, you need to set up your environment to point to that socket:
export MPD_HOST=/run/mpd/socket
when you do this, mpc add
or mpc insert
can successfully accept a file:
URL:
$ mpc insert "file:///data/incoming/files/111_scorpions_-_the_zoo.mp3"
$ mpc next
Scorpions - The Zoo
[playing] #23/39 0:00/5:30 (0%)
volume: n/a repeat: off random: off single: off consume: off
$
i did not find out how to play wav..but i forgot i found the solution (for mp3) and posted it here: https://forum.openwrt.org/viewtopic.php?id=41022
however, since stackoverflow always shows up top on google search i am pasting the same solution here in case it helps someone as well :
/etc/mpd.conf should be something approximately like this:
music_directory "/tmp"
playlist_directory "~/.mpd/playlists"
db_file "~/.mpd/database"
log_file "/tmp/mpdlog"
pid_file "~/.mpd/pid"
state_file "~/.mpd/state"
sticker_file "~/.mpd/sticker.sql"
user "root"
group "root"
bind_to_address "127.0.0.1"
log_level "verbose"
auto_update "yes"
auto_update_depth "3"
follow_outside_symlinks "yes"
follow_inside_symlinks "yes"
and then:
- /etc/init.d/mpd restart
- copy MP3 ( wav does not seem to work ) file to /tmp folder ( because music directory is the /tmp folder )
- mpc update
- mpc add file.mp3 ( adding /tmp/file.mp3 will NOT work )
- mpc play