我使用 Red5Pro for Xamarin 连接到音频投射。声音传到扬声器。在听的时候,我连接了我的蓝牙耳机。声音切换到他们,但很安静。
对于声音,我使用带有设置的 AVAudioSession:
类别- PlayAndRecord
CategoryOptions - DefaultToSpeaker | 允许蓝牙 | 允许蓝牙A2DP
并激活会话
设置 AVAudioSession 代码:
private static void SetupAVSession()
{
AVAudioSession.SharedInstance().SetActive(false);
AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.PlayAndRecord,
AVAudioSessionCategoryOptions.DefaultToSpeaker | AVAudioSessionCategoryOptions.AllowBluetooth | AVAudioSessionCategoryOptions.AllowBluetoothA2DP);
AVAudioSession.SharedInstance().SetActive(true);
}