安裝mopify
首先安裝mopify來當做音樂播放器
apt-get install mopidy
pip install Mopidy-Local-SQLite #安裝數(shù)據(jù)庫插件
配置mopify
sudo vi ~/.config/mopidy/mopidy.conf
內(nèi)容都統(tǒng)一修改為:
[m3u]
playlists_dir = /var/lib/mopidy/playlists
[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy
max_tracklist_length = 10000
restore_state = false
[logging]
color = true
console_format = %(levelname)-8s %(message)s
debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s
debug_file = /var/log/mopidy/mopidy-debug.log
config_file = /etc/mopidy/logging.conf
[audio]
mixer = software
mixer_volume =
#output = autoaudiosink
output = audioresample ! audio/x-raw,rate=48000,channels=2,format=S16LE ! audioconvert ! wavenc ! filesink location=/tmp/snapfifo? #輸出音頻到snapserver
buffer_time =
[proxy]
scheme =
hostname =
port =
username =
password =
[mpd]
enabled = true
hostname = ::
port = 6600
password =
max_connections = 20
connection_timeout = 60
zeroconf = Mopidy MPD server on $hostname
command_blacklist =
? listall
? listallinfo
default_playlist_scheme = m3u
[http]
enabled = true
hostname = ::
port = 6680
static_dir =
zeroconf = Mopidy HTTP server on $hostname
[stream]
enabled = true
protocols =
? http
? https
? mms
? rtmp
? rtmps
? rtsp
metadata_blacklist =
timeout = 5000
[m3u]
enabled = true
base_dir =
default_encoding = latin-1
default_extension = .m3u8
playlists_dir = /var/lib/mopidy/playlists
[softwaremixer]
enabled = true
[file]
enabled = true
media_dirs =
? $XDG_MUSIC_DIR|Music
? ~/|Home
excluded_file_extensions =
? .jpg
? .jpeg
show_dotfiles = false
follow_symlinks = false
metadata_timeout = 1000
[local]
enabled = true
#library = json
library = sqlite? #安裝Mopidy-Local-SQLite后使用此配置,會把樂庫的歌曲索引成數(shù)據(jù)庫究珊,讀寫速度更快,掃描后不用重啟程序
#media_dir = /var/lib/mopidy/media
media_dir = /home/Music #根據(jù)自己的文件夾修改
scan_timeout = 1000
scan_flush_threshold = 100
scan_follow_symlinks = false
excluded_file_extensions =
? .directory
? .html
? .jpeg
? .jpg
? .log
? .nfo
? .png
? .txt
確認配置文件是否正確:
sudo mopidyctl config
沒問題后直接運行掃描程序
sudo mopidyctl local scan
安裝snapcast
sudo apt-get install git
git clone https://github.com/badaix/snapcast.git
$ cd <snapcast dir>/externals
$ git submodule update --init --recursive
$ sudo apt-get install build-essential
$ sudo apt-get install libasound2-dev libvorbisidec-dev libvorbis-dev libflac-dev alsa-utils libavahi-client-dev avahi-daemon
Build Snapclient and Snapserver
cdinto the Snapcast src-root directory:
$ cd <snapcast dir>
$ make
Install Snapclient and/or Snapserver:
$ sudo make installserver
$ sudo make installclient
安裝mopidy-snapcast插件
Installation
To install:
git clone https://github.com/aawsome/mopidy-snapcast.git
sudo pip install .
PyPi distribution is coming soon...
Configuration
The extension is enabled by default.
Snapcast Server
Examples:
Use snapcast group with ID 'abc' of snapcastserver 'snapserver.local' on port 1234:
? ? [audio]
? ? mixer = snapcast
? ? [snapcast]
? ? enabled = true
? ? host = snapserver.local
? ? port = 1234
Use snapcast server on localhost:1705 and automatically detect group from stream connected to output:
? ? [audio]
? ? mixer = snapcast
? ? output = audioresample ! audio/x-raw,rate=48000,channels=2,format=S16LE ! audioconvert ! wavenc ! filesink location=/tmp/snapfifo
(-> Group linked to stream which is connected to /tmp/snapfifo is used!)
安裝完成后重啟電腦 mopidy和snapcast自動啟動
android客戶端
mopidy客戶端https://github.com/gateship-one/malp
snapcast客戶端https://github.com/badaix/snapdroid
參考:
http://docs.mopidy.com/en/latest/audio/
https://github.com/aawsome/mopidy-snapcast
https://github.com/badaix/snapcast
https://github.com/mopidy/mopidy
https://github.com/jxjhheric/homeassistant-with-snapcast
https://www.home-assistant.io/blog/2016/02/18/multi-room-audio-with-snapcast/