I'm writing a media player in Python that can play music in connected Bluetooth speakers. I got a speaker with 3 control buttons volume up/down, play/pause. My code (using mpv) is playing music fine, the volume controls are working too. But I could not get the play/pause button working, here is what I found:
sudo evtest sees the event:
Testing ... (interrupt to exit)
Event: time 1661208706.167140, type 1 (EV_KEY), code 200 (KEY_PLAYCD), value 1
Event: time 1661208706.167140, -------------- SYN_REPORT ------------
Event: time 1661208706.255603, type 1 (EV_KEY), code 200 (KEY_PLAYCD), value 0
Event: time 1661208706.255603, -------------- SYN_REPORT ------------
sudo btmon sees them too:
< ACL Data TX: Handle 11 flags 0x00 dlen 12 #2575 [hci0] 124.622157
Channel: 66 len 8 [PSM 23 mode Basic (0x00)] {chan 2}
AVCTP Control: Response: type 0x00 label 2 PID 0x110e
AV/C: Accepted: address 0x48 opcode 0x7c
Subunit: Panel
Opcode: Passthrough
Operation: 0x44 (PLAY Pressed)
Length: 0x00
> ACL Data RX: Handle 11 flags 0x02 dlen 12 #2576 [hci0] 124.623006
Channel: 66 len 8 [PSM 23 mode Basic (0x00)] {chan 2}
AVCTP Control: Command: type 0x00 label 3 PID 0x110e
AV/C: Control: address 0x48 opcode 0x7c
Subunit: Panel
Opcode: Passthrough
Operation: 0xc4 (PLAY Released)
Length: 0x00
dbus-monitor --system displays the volume change events, but does nothing when I press the "play" button.
How could I catch these events in a python program? I can access dbus events with dbus-python, but the play event does not get submitted there.