Silent if connect headphones

160 Views Asked by At

I connect to the audio cast using Red5Pro for Xamarin. The sound goes to the speaker. While listening, I connect my Bluetooth headphones. The sound switches to them, but it's quiet.

For the sound, I use AVAudioSession with the settings:

Category - PlayAndRecord

CategoryOptions - DefaultToSpeaker | AllowBluetooth | AllowBluetoothA2DP

And activate the session

Setup AVAudioSession code:

    private static void SetupAVSession()
    {
        AVAudioSession.SharedInstance().SetActive(false);
        AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.PlayAndRecord,
        AVAudioSessionCategoryOptions.DefaultToSpeaker | AVAudioSessionCategoryOptions.AllowBluetooth | AVAudioSessionCategoryOptions.AllowBluetoothA2DP);
        AVAudioSession.SharedInstance().SetActive(true);
    }
1

There are 1 best solutions below

0
On

I use SetPreferredSampleRate with value 16000 and sound work

AVAudioSession.SharedInstance().SetPreferredSampleRate(16000, out NSError sampleHardwareErr2);