Raspberry Pi3からBluetoothスピーカにペアリングして音楽再生する。
なおPiZeroWで同じ設定をしたが非力で音飛びするようだった。
以下のWebページの内容をトレースして設定した。
《参照》
Raspberry PI 3 で Bluetooth(A2DP)
http://qiita.com/nattof/items/3db73a95e63100d7580a
(1) PulseAudioのインストール
(2) PulseAudioの設定
3つのファイルを設定する。
(3) 使用したbluetoothスピーカ
![]()
2年くらい前にSoftBankのキャンペーンでもらったOnyx Studioと、ことしの1月にauのキャンペーンでもらった座布団つきのGH-OTOMO。ともに再生は確認できたが、GH-OTOMOはボリュームがないので、AlsaMixerでの音量調整が必要。
(4) PulseAudioの起動
(5) bluetoothスピーカへの接続
bluetoothスピーカとペアリングして接続する
(6) mplayerでの再生例
●1 bluetoothスピーカ再生
# mplayer --ao=pulse /usr/local/etc/mdetect/Mp3/01_Beautiful_World.mp3
# mplayer --ao=pulse 01_FIGHT_WITH_LOVE.m4a
●2 ミニプラグジャック再生
# mplayer --ao=alsa /usr/local/etc/mdetect/Mp3/01_Beautiful_World.mp3
●3 MUSIC BIRDデジタル音楽放送 岡山県 コミュニティFM レディオ モモ
# mplayer --ao=pulse --cache=900 --quiet 'http://musicbird-hls.leanstream.co/musicbird/JCB079.stream/playlist.m3u8?args=web_03'
なおPiZeroWで同じ設定をしたが非力で音飛びするようだった。
以下のWebページの内容をトレースして設定した。
《参照》
Raspberry PI 3 で Bluetooth(A2DP)
http://qiita.com/nattof/items/3db73a95e63100d7580a
(1) PulseAudioのインストール
# apt-get install pulseaudio-module-bluetooth
(2) PulseAudioの設定
3つのファイルを設定する。
○その1
# cat << EOF > /etc/systemd/system/pulseaudio.service
[Unit]
Description=Pulse Audio
[Service]
Type=simple
ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm
[Install]
WantedBy=multi-user.target
EOF
○その2
# cat << EOF > /etc/dbus-1/system.d/pulseaudio-bluetooth.conf
<busconfig>
<policy user="pulse">
<allow send_destination="org.bluez"/>
</policy>
</busconfig>
EOF
○その3
# cat << EOF >> /etc/pulse/system.pa
### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif
EOF
(3) 使用したbluetoothスピーカ

2年くらい前にSoftBankのキャンペーンでもらったOnyx Studioと、ことしの1月にauのキャンペーンでもらった座布団つきのGH-OTOMO。ともに再生は確認できたが、GH-OTOMOはボリュームがないので、AlsaMixerでの音量調整が必要。
(4) PulseAudioの起動
○pulseaudioサービスを起動
# systemctl start pulseaudio.service
○pulseaudioサービスを自動で起動
# systemctl enable pulseaudio.service
○bluetoothの再起動
# /etc/init.d/bluetooth restart
[ ok ] Restarting bluetooth (via systemctl): bluetooth.service.
(5) bluetoothスピーカへの接続
bluetoothスピーカとペアリングして接続する
# bluetoothctl #bluetoothコントロールツール
[NEW] Controller 43:43:A1:12:AA:AA rapi3 [default]
[bluetooth]# scan on #スキャン開始
Discovery started
[CHG] Controller 43:43:A1:12:AA:AA Discovering: yes
[NEW] Device 0C:A6:94:0D:ZZ:ZZ HK Onyx Studio
[bluetooth]# pair 0C:A6:94:0D:ZZ:ZZ #Onyx Studioとペアリング
Attempting to pair with 0C:A6:94:0D:ZZ:ZZ
[CHG] Device 0C:A6:94:0D:ZZ:ZZ Connected: yes
[CHG] Device 0C:A6:94:0D:ZZ:ZZ Paired: yes
Pairing successful
[bluetooth]# connect 0C:A6:94:0D:ZZ:ZZ #Onyx Studioに接続
Attempting to connect to 0C:A6:94:0D:ZZ:ZZ
[CHG] Device 0C:A6:94:0D:ZZ:ZZ Connected: yes
Connection successful
[bluetooth]# trust 0C:A6:94:0D:ZZ:ZZ #Onyx Studioを信頼
[CHG] Device 0C:A6:94:0D:ZZ:ZZ Trusted: yes
Changing 0C:A6:94:0D:ZZ:ZZ trust succeeded
[bluetooth]# info 0C:A6:94:0D:ZZ:ZZ #Onyx Studioの接続情報
Device 0C:A6:94:0D:ZZ:ZZ
Name: HK Onyx Studio
Alias: HK Onyx Studio
Class: 0x240414
Icon: audio-card
Paired: yes
Trusted: yes
Blocked: no
Connected: yes
LegacyPairing: no
UUID: Audio Sink (XXX..XXX)
UUID: A/V Remote Control Target (XXX..XXX)
UUID: A/V Remote Control (XXX..XXX)
[bluetooth]# scan off #スキャン終了
Discovery stopped
[CHG] Controller 43:43:A1:12:AA:AA Discovering: no
[bluetooth]# devices #検出したデバイス
Device 08:62:66:17:XX:XX 2F_NPlayer_2nd
Device 08:62:66:17:YY:YY 1F_NPlayer_1st
Device FC:58:FA:00:ZZ:ZZ GH-OTOMO
Device 0C:A6:94:0D:ZZ:ZZ HK Onyx Studio
[bluetooth]#
[bluetooth]# quit #終了
[DEL] Controller 43:43:A1:12:AA:AA rapi3 [default]
音を出すユーザーを「pulse-access」グループに追加
# gpasswd -a root pulse-access
# gpasswd -a user pulse-access
# grep pulse-access /etc/group
pulse-access:x:117:root,user #追加されたユーザを見る
(6) mplayerでの再生例
●1 bluetoothスピーカ再生
# mplayer --ao=pulse /usr/local/etc/mdetect/Mp3/01_Beautiful_World.mp3
# mplayer --ao=pulse 01_FIGHT_WITH_LOVE.m4a
●2 ミニプラグジャック再生
# mplayer --ao=alsa /usr/local/etc/mdetect/Mp3/01_Beautiful_World.mp3
●3 MUSIC BIRDデジタル音楽放送 岡山県 コミュニティFM レディオ モモ
# mplayer --ao=pulse --cache=900 --quiet 'http://musicbird-hls.leanstream.co/musicbird/JCB079.stream/playlist.m3u8?args=web_03'