在这里插入图片描述
借助shairport-sync,可以让普通音响变成AirPlay无线音响,由于树莓派天生的低功耗,做这种事情最适合。所以架构就是树莓派安装Ubuntu24.04,在树莓派上安装shairport-sync,树莓派再通过3.5mm线连接音响。

安装Ubuntu24.04

我用的是Mac
打开 终端,运行以下命令查看 U 盘设备路径:

diskutil list

找到 U 盘对应的设备路径(如 /dev/disk2)。
卸载但不弹出 U 盘:

diskutil unmountDisk /dev/disk2

使用 dd 命令将 ISO 文件写入 U 盘:

sudo dd if=/Users/microfat/Downloads/ubuntu-24.04.1-preinstalled-server-arm64+raspi.img  of=/dev/disk2 bs=4M

执行以下命令确保写入完成:

sync

安全弹出 U 盘:

diskutil eject /dev/disk2

插入sd卡,启动树莓派
默认账号:ubuntu,密码:ubuntu

连接wifi

sudo vim /etc/netplan/50-cloud-init.yaml
network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
    wifis:
        wlan0:
            dhcp4: true
            access-points:
                "wifi名字":
                    hidden: true
                    password: "wifi密码"

如果wifi隐藏则记得

hidden: true
sudo netplan try
sudo netplan apply

重启就能连上Wi-Fi了

SSH远程连接

sudo vim /etc/ssh/sshd_config
PubkeyAuthentication yes
PasswordAuthentication yes
KbdInteractiveAuthentication yes

重启SSH服务

sudo systemctl restart ssh

就可以通过密码进行远程连接了

安装启动shairport-sync

sudo apt install shairport-sync
sudo systemctl start shairport-sync

设置开机自启:

sudo systemctl enable shairport-sync

检查服务状态:

sudo systemctl status shairport-sync

修改配置文件

sudo vim /etc/shairport-sync.conf

20241208更新

以上安装方式安装的版本太低了,不支持Airplay2。想要使用Airplay2就必须用高版本的shairport-sync,我试过使用编译安装,但没成功。使用Docker可以安装最新版本,然后就能使用Airplay2了。
在这里插入图片描述

>>> docker run -d --restart always --name Airplay2 --net host --device /dev/snd mikebrady/shairport-sync
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐