如果你已经填平了上面的坑,那么就已经可以离开了。
树莓派 3B+ Buster,在 Docker 下安装 Hassio
在 Docker 外,也即正常 Raspbian 环境下安装 Mopidy在 Docker 内安装 Mopidy(Hassio 的 Add-On 方式) 此 Add On 不能蓝牙输出为了方便起见,下面使用远程桌面进行蓝牙的连接操作(实测开机后可以自动重新连接,无需其它配置)
打开蓝牙,添加蓝牙音箱设备如下图所示将音频输出修改为蓝牙音箱(天猫精灵 IN 糖)ps:命令行连接蓝牙设备需要使用 bluetoothctl 工具,自行搜索或参考论坛教程上一步会把默认的音频输出设置为蓝牙音箱,在 ~/.asoundrc 文件中可以看到类似如下的配置信息:pcm.!default { type asym playback.pcm { type plug slave.pcm "output" } capture.pcm { type plug slave.pcm "input" } } pcm.output { type bluealsa device "D4:4B:B6:0E:4D:2D" profile "a2dp" } ctl.!default { type bluealsa } pcm.input { type hw card 1 } 然后把你的 ~/.asoundrc 拷贝到 /etc/asound.conf有关 Asoundrc 更多信息,参考官方 wiki至此我们把音频输出设置为了蓝牙音箱,上传一个 wav 文件到树莓派,使用 aplay /path/to/your/wav/file.wav 命令测试,音频应该会从蓝牙音箱播出。没问题的话,就进行下一步。
根据文档描述安装:
1. Add the archive’s GPG key: wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add - 2. Add the APT repo to your package sources: sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/buster.list 3. Or, if you run an older Debian/Ubuntu distro (including Ubuntu 18.04 LTS): sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/stretch.list 4.Install Mopidy and all dependencies: sudo apt-get update sudo apt-get install mopidy ps:实际上我只执行了第 4 步,用的 apt 源是中科大源: deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ buster main ui编辑 /etc/mopidy/mopidy.conf,填入以下内容(没有则创建,实际上在家目录下有 ~/.config/mopidy/mopidy.conf):
[core] cache_dir = /var/cache/mopidy config_dir = /etc/mopidy data_dir = /var/lib/mopidy [logging] config_file = /etc/mopidy/logging.conf debug_file = /var/log/mopidy/mopidy-debug.log [local] media_dir = /var/lib/mopidy/media [m3u] playlists_dir = /var/lib/mopidy/playlists [mpd] enabled = true hostname = 127.0.0.1 port = 6600 [audio] output = alsasink注意:
最简的配置,只要包含 [mpd] 那一项即可(必须包含,才可以使能 mopidy 服务)
默认 audio 输出使用的是 autoaudiosink(参见 audio/output),但是为了使用蓝牙音箱,配置文件里必须添加 audio 项,把输出改为 alsasink。否则 Mopidy 就会把声音输出到 3.5mm 或 HDMI 接口。
此坑参考自 raspberrypi-installation: 树莓派桌面镜像用户需要:sudo adduser mopidy video这样 Mopidy 即可开机自动运行,至此 Mopidy 就安装完成了,有关它的 http 服务或其它配置和扩展,参考官方文档。
添加 Add-On 仓库:https://github.com/bestlibre/hassio-addons,然后安装 mopidy 即可。若下载不顺利,可以尝试全局科学上网。
可在 SYSTEM 标签下查看日志,以判断拉取镜像是否成功在开发者工具中调用: DATA 填入一下数据:
entity_id: media_player.mpd message: hello,世界点击 CALL SERVICE,稍等两秒,让系统跑一会~