普通音箱加上淘汰的机顶盒,变为Airplay2音箱,和HomePod同步播放,这里使用的方案是机顶盒安装shairport-sync+普通音箱。
这期主要介绍的是如何单独通过普通盒子安装Armbian,再Shairport-sync,连接有线音箱支持Airplay2。 这期方案是上期方案《Shairport-Sync+Snapcast》的补充方案。
shairport-sync正式发布支持Airplay2,隔空播放2,并且支持了Docker。
安装设备介绍,需要能安装Linux的设备。包括服务器,树莓派,运营商的机顶盒等。如N1/HK1Box/移动魔百盒等。这种设备是最便宜,移动的盒子不到50元。如没有音频输出口的需要加一个USB-DAC,或者USB音箱。盒子介绍,Ophub的大佬Flippy提供了各种盒子的Armbian固件,点这里。
有线有源音箱,自带音频输入的即可,带3.5mm插头的音箱比较通用。
这里选用了安装好Linux的锐角云。
惠威桌面音箱M10.音箱的3.5mm插头插入锐角云的音频输出口。
1. SSH连接上锐角云,安装准备包
```
# apt update
# apt install --no-install-recommends build-essential git autoconf automake libtool \
libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev \
libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid-dev libgcrypt-dev xxd
```
2. 安装 nqptp
```
$ git clone https://github.com/mikebrady/nqptp.git
$ cd nqptp
$ autoreconf -fi
$ ./configure --with-systemd-startup
$ make
# make install
```
```
# systemctl enable nqptp
# systemctl start nqptp
```
3. 安装Mqtt client
```
apt install libmosquitto-dev
```
4. 安装Shairport-Sync,这里没有使用Apple的解码包 --with-apple-alac
```
$ git clone https://github.com/mikebrady/shairport-sync.git
$ cd shairport-sync
$ autoreconf -fi
$ ./configure --sysconfdir=/etc --with-alsa \
--with-soxr --with-avahi --with-ssl=openssl --with-systemd --with-airplay-2 \
--with-stdout --with-pipe --with-metadata \
--with-mqtt-client
$ make
# make install
```
5. 配置文件
```
#/etc/shairport-sync.conf
general = {
name = "惠威音箱";
output_backend = "alsa";
port = 7100; #7000
#alac_decoder = "hammerton"; #apple
};
alsa =
{
output_device = "default";
};
metadata =
{
enabled = "yes";
include_cover_art = "yes";
cover_art_cache_directory = "/tmp/shairport-sync/.cache/coverart";
pipe_name = "/tmp/shairport-sync-metadata";
pipe_timeout = 5000;
};
mqtt =
{
enabled = "yes";
hostname = "192.168.1.xx";
port = 1883;
username = "mqtt";
password = "xxxx";
topic = "player/shairport";
publish_parsed = "yes";
empty_payload_substitute = "--";
publish_cover = "yes";
enable_remote = "yes";
};
sessioncontrol =
{
active_state_timeout = 30.0;
allow_session_interruption = "yes";
session_timeout = 120;
};
```
6. 启动
```
# systemctl enable shairport-sync
# systemctl restart shairport-sync
```
7. 日志
```
systemctl enable shairport-sync
```
8. 接入Home-assistant
```
# Shairport Sync media player for Home Assistant
# https://github.com/parautenbach/hass-shairport-sync
# https://www.home-assistant.io/integrations/universal/
media_player:
- platform: shairport_sync
name: shairport
topic: player/shairport
```
## 二、测试播放
## 三、加入苹果家庭APP,HomeKit。