CHIP-bluetooth-speaker icon indicating copy to clipboard operation
CHIP-bluetooth-speaker copied to clipboard

Play sounds when devices connect/disconnect

Open hadess opened this issue 8 years ago • 3 comments

This makes it easier to know if the speaker's volume is correctly set, if we connected properly, etc.

The "device-added" and "device-removed" in sound-theme-freedesktop are probably pretty good sounds to start with.

hadess avatar Jul 16 '17 16:07 hadess

Using something similar to this script: https://github.com/adenbeckitt/Bluez-AVRCP-Volume-Control should work.

Connecting:

/org/bluez/hci0/dev_00_00_00_00_00_00: org.freedesktop.DBus.Properties.PropertiesChanged ('org.bluez.MediaControl1', {'Connected': <true>}, @as [])
<short pause>
/org/bluez/hci0/dev_00_00_00_00_00_00/fd1: org.freedesktop.DBus.Properties.PropertiesChanged ('org.bluez.MediaTransport1', {'State': <'active'>}, @as [])

Disconnecting:

/org/bluez/hci0/dev_00_00_00_00_00_00: org.freedesktop.DBus.Properties.PropertiesChanged ('org.bluez.MediaControl1', {'Connected': <false>}, @as [])

So, when Connected = true, we'd pause for about 0.5 sec, and play a sound if the State was anything but active. We'd always play a sound if Connected is false.

hadess avatar Jul 20 '17 06:07 hadess

The freedesktop sound theme has pretty good sounds we could use to play back.

hadess avatar Jul 20 '17 06:07 hadess

Note implemented exactly like the above. Note that we received a "Connected" signal even if the device was already connected, when we try to disconnect. The code also doesn't handle multiple devices being connected.

hadess avatar Jul 22 '17 18:07 hadess