树莓派0W连接蓝牙音箱(实际也适用其他型号的派)

为了能让我的pi0w可以连接蓝牙音箱,在网上逛了两天,看了很多资料多数都不好用,很多是因为作者太不负责任,写的东西,很多都写的不清楚,导致不成功。这个方法是我参考了别人的方法,经过自己实践总结出来的。首先感谢原作者,原文件链接:https://bbs.hassbian.com/thread-3404-1-1.html话不多说,直接上成功的方法:
一、安装软件。
apt-get  install pulseaudio pulseaudio-module-bluetooth bluez  bluez-firmware
二、添加用户:
    adduser root pulse-access    
    adduser pi pulse-access
三、修改文件:
  1. vim /etc/dbus-1/system.d/bluetooth.conf
    在</busconfig>之前添加如下内容,注意不是修改内容,这步很关键。
  <policy user="pulse">
    <allow send_destination="org.bluez"/>
  </policy>
  1. vim /etc/pulse/system.pa在文件的最后添加,不是修改原内容。
### Bluetooth Support
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
load-module module-bluetooth-policy
.endif

  1. vim /etc/pulse/default.pa 在原文load-module module-native-protocol-tcp后面添加auth-anonymous=1。
load-module module-native-protocol-tcp auth-anonymous=1
  1. vim /etc/pulse/daemon.conf(这个文件修不修改都好像没什么影响。)
resample-method = speex-fixed-3
  1. vim /etc/systemd/system/pulseaudio.service(这个文件原来没有,要新建。添加如下内容。
[Unit]
Description=Pulse Audio
[Service]
Type=simple
ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm --exit-idle-time=-1
[Install]
WantedBy=multi-user.target

四、开启服务:
systemctl daemon-reload (重启加载进程)
systemctl restart Bluetooth (重启bluetooth进程)
systemctl start pulseaudio.service 启动pulseaudio进程)
systemctl enable pulseaudio.service (pulseaudio进程开机自启动)
systemctl status Bluetooth (查看bluetooth进程状态)

五、连接蓝牙音箱:

#bluetoothctl
[bluetooth]#power on
[bluetooth]#agent on
[bluetooth]#default-agent
[bluetooth]#scan on (扫描附近蓝牙设备)
[bluetooth]#pair xx:xx:xx:xx:xx:xx (配对(后面是蓝牙地址))
[bluetooth]#trust xx:xx:xx:xx:xx:xx (信任蓝牙设备)
[bluetooth]#connect xx:xx:xx:xx:xx:xx (连接蓝牙设备)
[bluetooth]#scan off (关闭扫描)
[bluetooth]#exit
有的设备在这步的时候连接上后马上会断,不影响,exit蓝牙后,关闭蓝牙音箱再打开就会自动连接,正常使用了。

六、播放音乐

mplayer file.mp3

享受音乐吧!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kim5659

你的鼓励是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值