Linux命令行操作蓝牙播放步骤

蓝牙播放步骤:

一. 连接蓝牙, 一般用root用户操作

  1. hciconfig hci0 up
  2. bluetoothd服务已起来
  3. bluetoothctl 命令进去操作
    [JBL Flip 5]# connect D8:37:3B:6B:45:D6 我的音箱
    pair D8:37:3B:6B:45:D6
    connect D8:37:3B:6B:45:D6

接下来两大步骤换成非root用户操作,(root操作一直起不来)

二. 设置声卡声道

1
2
3
4
5
1. pulseaudio --start
2. pacmd list-cards
pacmd set-card-profile 3 a2dp_sink
3. pacmd list-sinks
pacmd set-default-sink 3

三. 播放音乐

1
play /home/dtt/bluetooth/xajh.mp3

四. 总结,在orangepi上只需执行

1
2
3
4
5
6
7
8

bluetoothctl connect D8:37:3B:6B:45:D6

pulseaudio --start
pacmd set-card-profile 3 a2dp_sink
pacmd set-default-sink 3

play /home/dtt/bluetooth/xajh.mp3