Hi,
I'm using the latest version of the audio_session package on both iOS and Android.
I noticed that devicesChangedEventStream works correctly when a Bluetooth device is connected. The stream emits an event, and devicesAdded contains the connected device.
However, when the Bluetooth device is disconnected, no event is emitted. As a result, devicesRemoved is never populated, and I have no way to detect that the Bluetooth device has been removed.
Is this expected behaviour on iOS, or is it a bug? If this is a known limitation, could you please suggest a workaround to detect Bluetooth device disconnection?
Here is my code:
audioSession.devicesChangedEventStream.listen((event) {
print('Devices added: ${event.devicesAdded}');
print('Devices removed: ${event.devicesRemoved}');
Future.delayed(const Duration(milliseconds: 1000), () {
updateAudioSwitchList(audioSession);
});
});
Expected behaviour
- An event should be emitted when a Bluetooth device is disconnected.
devicesRemoved should contain the disconnected device so that the application can update the available audio routes.
Actual behaviour
- An event is emitted only when the Bluetooth device is connected.
- No event is received when the Bluetooth device is disconnected.
I would appreciate any guidance or workaround for handling Bluetooth disconnection on iOS.
Thank you for your time and support!
Hi,
I'm using the latest version of the
audio_sessionpackage on both iOS and Android.I noticed that
devicesChangedEventStreamworks correctly when a Bluetooth device is connected. The stream emits an event, anddevicesAddedcontains the connected device.However, when the Bluetooth device is disconnected, no event is emitted. As a result,
devicesRemovedis never populated, and I have no way to detect that the Bluetooth device has been removed.Is this expected behaviour on iOS, or is it a bug? If this is a known limitation, could you please suggest a workaround to detect Bluetooth device disconnection?
Here is my code:
Expected behaviour
devicesRemovedshould contain the disconnected device so that the application can update the available audio routes.Actual behaviour
I would appreciate any guidance or workaround for handling Bluetooth disconnection on iOS.
Thank you for your time and support!