[bug] [iOS only] When call setMicrophoneEnabled, audio output switched from Headphones to Speaker
UserJah opened this issue · comments
Describe the bug
- When I connecting to room with headphones (bluetooth) I hear participants from headphones. But when I call setMicrophoneEnabled(true) audio output automatically switched to speakerphone.
Also, Hardware.instanse.enumerateDevices() return only one audio Input - (speaker)
To Reproduce
- connect to room with headphones (bluetooth)
- enable microphone
Expected behavior
Enable microphone should not switch audio output automatically.
P.S: I'm guessing this may be related to AppleAudioMode. Is there any way to change it?
Platform information
- Flutter version:
[✓] Flutter (Channel stable, 3.16.0, on macOS 13.4 22F66 darwin-arm64, locale ru-AE)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.84.2)
[✓] Connected device (3 available)
[✓] Network resources
• No issues found!
- Plugin version: 1.5.3
- Flutter target OS: iOS
- Flutter target OS version:12.1
- Flutter console log:
hey @UserJah, I saw you made some changes in your fork, is it effective?
What model of Bluetooth headset are you using?
I tested Air Pods Pro on iOS and it seems to work as expected
- Connect air pods
- Turn off fast connect and connect to the room
- Sound output from air pods
- Enable microphone on iOS
- The sound is not output from the speaker.
Hey @cloudwebrtc!
I'm using JBL TUNE760NC. For my case it's happens because this code:
https://github.com/livekit/client-sdk-flutter/blob/f5c681d5096e23dc332074e273a9dedc77d11dd6/lib/src/track/audio_management.dart#L128C5-L133C6
Hardware.instanse.setSpeakerPhoneOn(true)
works only if _preferSpeakerOutput = false
.
In my case I'm just use await Hardware.instance.setPreferSpeakerOutput(true)
In case my fork - I found better solution. I'm just overide this function
https://github.com/livekit/client-sdk-flutter/blob/f5c681d5096e23dc332074e273a9dedc77d11dd6/lib/src/track/audio_management.dart#L36C1-L39C1
like
onConfigureNativeAudio = (_) async {
return NativeAudioConfiguration(
appleAudioCategory: AppleAudioCategory.playAndRecord,
appleAudioCategoryOptions: <AppleAudioCategoryOption>{
AppleAudioCategoryOption.allowBluetooth,
AppleAudioCategoryOption.interruptSpokenAudioAndMixWithOthers,
},
appleAudioMode: AppleAudioMode.videoChat,
);
};
because in my case I don't need dependence of AudioModes on count audio tracks
A similar bug is also present in my users. I'm still waiting for a solution. #376
hi, any solution ?
fixed #518