本文介绍在Linux系统(基于Ubuntu和Arch Linux)中安装配置mpd和ncmpcpp的方法。
简介
音乐播放器守护程序(MPD)是一个灵活,功能强大的服务器端应用程序,用于播放音乐,通过插件和库,它可以播放各种声音文件,同时由其网络协议控制,为了与mpd交互,需要一个客户端程序,最常用的客户端应用程序是:
ncmpcpp:几乎完全克隆了ncmpc,其中包含一些用C++编写的新功能(标签编辑器,搜索引擎)。
ncmpc:为mpd Ncurses客户端。
mpc:MPD服务器的命令行用户界面。
在Linux中安装mpd
1、在Arch Linux中安装mpd,Arch Linux的Mpd可用于官方存储库和AUR:
$ sudo pacman -S mpd --noconfirm
$ yay -S --needed --noconfirm mpd-git
或者:
$ yaourt -S mpd-git
2、在Ubuntu中安装mpd,它可以在官方存储库中使用:
sudo apt-get install mpd
配置mpd
现在创建mpd所需的目录,让我们创建默认配置目录和播放列表目录:
$ mkdir -p ~/.mpd/playlists/
在~/.mpd目录下创建mpd.conf文件,内容可以根据你的喜好进行修改:
$ vim ~/.mpd/mpd.conf
添加以下内容:
bind_to_address "127.0.0.1"
#bind_to_address "~/.mpd/socket"
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"
audio_output {
type "pulse"
name "pulse audio"
device "pulse"
mixer_type "hardware"
}
audio_output {
type "fifo"
name "my_fifo"
path "/tmp/mpd.fifo"
format "44100:16:2"
}
要使用alsa而不是pulseaudio,第一个audio_output块应如下所示:
audio_output {
type "alsa"
name "Alsa for audio sound card"
mixer_type "software" # optional
}
将你的mpd用户名添加到你的登录组和音频组:
$ sudo gpasswd -a mpd
$ chmod 710 ~/
$ sudo gpasswd -a mpd audio
通过启动mpd测试配置文件是否有效:
$ mpd
$ ss -tunelp | grep 6600
tcp LISTEN 0 5 127.0.0.1:6600 *:* users:(("mpd",pid=10906,fd=8)) uid:1000 ino:269403 sk:8
mpd.service systemd单元可用于/usr/lib/systemd/system/mpd.service上的autostart。
安装和配置ncmpcpp
1、在Arch Linux中安装ncmpcpp:
sudo pacman -S ncmpcpp --noconfirm
AUR的最新开发版本:
yay --needed --noconfirm -S ncmpcpp-git
2、在Ubuntu中安装和配置ncmpcpp
使用apt-get安装ncmpcpp:
sudo apt-get install ncmpcpp
mkdir -p ~/.ncmcpp/lyrics
添加ncmpcpp配置文件:
$ vim ~/.ncmpcpp/config
添加以下内容:
##
# Files
mpd_music_dir = "~/Music"
lyrics_directory = ~/.ncmpcpp/lyrics
ncmpcpp_directory = ~/.ncmpcpp
mpd_host = "localhost"
mpd_port = "6600"
mpd_connection_timeout = "5"
mpd_crossfade_time = "5"
# Playlist
playlist_disable_highlight_delay = "0"
playlist_display_mode = "columns"
playlist_show_remaining_time = "yes"
browser_display_mode = "columns"
autocenter_mode = "yes"
fancy_scrolling = "yes"
follow_now_playing_lyrics = "yes"
display_screens_numbers_on_start = "yes"
ignore_leading_the = "yes"
lyrics_database = "1"
song_columns_list_format = "(10)[blue]{l} (30)[green]{a} (30)[magenta]{b} (50)[yellow]{t}"
colors_enabled = "yes"
main_window_color = "white"
main_window_highlight_color = "blue"
header_window_color = "cyan"
volume_color = "red"
progressbar_color = "cyan"
statusbar_color = "white"
active_column_color = "cyan"
active_window_border = "blue"
alternative_header_first_line_format = "$0$aqqu$/a {$7%a - $9}{$5%t$9}|{$8%f$9} $0$atqq$/a$9"
alternative_header_second_line_format = "{{$6%b$9}{ [$6%y$9]}}|{%D}"
song_list_format = "{$3%n │ $9}{$7%a - $9}{$5%t$9}|{$8%f$9}$R{$6 │ %b$9}{$3 │ %l$9}"
user_interface = "alternative"
#user_interface = "classic"
default_place_to_search_in = "database"
# visualizer
visualizer_fifo_path = "/tmp/mpd.fifo"
visualizer_output_name = "my_fifo"
visualizer_sync_interval = "12"
#visualizer_type = "wave" (spectrum/wave)
visualizer_type = "spectrum" (spectrum/wave)
visualizer_in_stereo = "yes"
visualizer_look = "+|"
## Navigation ##
cyclic_scrolling = "yes"
header_text_scrolling = "yes"
jump_to_now_playing_song_at_start = "yes"
lines_scrolled = "2"
## Other ##
system_encoding = "utf-8"
regular_expressions = "extended"
## Selected tracks ##
selected_item_prefix = "* "
discard_colors_if_item_is_selected = "no"
## Seeking ##
incremental_seeking = "yes"
seek_time = "1"
## Visivility ##
header_visibility = "yes"
statusbar_visibility = "yes"
titles_visibility = "yes"
progressbar_look = "=>-"
progressbar_boldness = "yes"
progressbar_elapsed_color = "white"
now_playing_prefix = "> "
song_status_format = " $2%a $4》$3》 $8%t $4》$3》 $5%b "
autocenter_mode = "yes"
centered_cursor = "yes"
# Misc
display_bitrate = "yes"
# enable_window_title = "no"
follow_now_playing_lyrics = "yes"
ignore_leading_the = "yes"
empty_tag_marker = ""
启动ncmpcpp并更新mpd数据库
要启动ncmpcpp,只需在终端上输入命令:
$ ncmpcpp
一旦启动,输入u更新数据库,它将自动发现~/Music/目录中的歌曲:
u
页面大致如下图:
在ncmpcpp上看到的Mpd播放列表。
如果你按8或F8,会看到音乐可视化器:
ncmpcpp快捷键列表
键盘按键
功能
Down j
向下移动光标
Page Up
向上翻页
Page Down
向下翻页
Home
主页
End
结束
Tab
在播放列表和浏览器之间切换
1 F1
帮助屏幕
2 F2
播放列表屏幕
3 F3
浏览屏幕
4 F4
搜索引擎
5 F5
媒体库
6 F6
播放列表编辑器
7 F7
标签编辑器
0 F10
时钟屏幕
相关主题