linux上的mpc / mpd:如何播放本地wav文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15659067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mpc / mpd on linux: how to play local wav file
提问by Shrouk Khan
I am trying to add a local file to mpd ( through mpc ) and play it . my platform is OpenWRT embedded linux .
我正在尝试将本地文件添加到 mpd(通过 mpc)并播放它。我的平台是 OpenWRT 嵌入式 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 .
这里的正确语法到底是什么?mpc / mpd 的手册页真的不是很清楚。
采纳答案by Shrouk Khan
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
我没有找到如何播放 wav ..但我忘了我找到了解决方案(用于 mp3)并将其发布在这里: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 :
然而,由于stackoverflow总是出现在谷歌搜索的顶部,我在这里粘贴相同的解决方案,以防万一它也有助于某人:
/etc/mpd.conf should be something approximately like this:
/etc/mpd.conf 应该是这样的:
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
- /etc/init.d/mpd 重启
- 将 MP3(wav 似乎不起作用)文件复制到 /tmp 文件夹(因为音乐目录是 /tmp 文件夹)
- mpc更新
- mpc add file.mp3(添加 /tmp/file.mp3 不起作用)
- mpc 播放
回答by Jules
Your second attempt was almostright. 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:
你的第二次尝试几乎是正确的。您遇到的问题是,mpd
它只允许file:
通过本地连接将URL 传递给它,它通过要求您在其unix-domain socket上进行连接来强制执行。所以,在mpd.conf
你需要有这样一行:
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).
(根据你的系统,你可能要更改/run
到/var/run
-我的版本报价为最新版本的Debian的是正确的或Ubuntu,但其他人可能会有所不同)。
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 add
或者mpc insert
可以成功接受一个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
$