SnapCast-Mopidy实现多房间同步

安装mopify

首先安装mopify来当做音乐播放器

apt-get install mopidy

pip install Mopidy-Local-SQLite #安装数据库插件

配置mopify

sudo vi ~/.config/mopidy/mopidy.conf

内容都统一修改为:

[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后使用此配置,会把乐库的歌曲索引成数据库,读写速度更快,扫描后不用重启程序

#media_dir = /var/lib/mopidy/media

media_dir = /home/Music #根据自己的文件夹修改

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 /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

$ 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/

你可能感兴趣的:(SnapCast-Mopidy实现多房间同步)