how to route iPhone audio to the bluetooth headset

前端 未结 2 1470
说谎
说谎 2020-12-01 03:42

I\'m attempting to output audio to the bluetooth headset (not A2DP) using AVAudioPlayer, AVAudioSession and AudioSessionSetProperty.

There seems to be functions to s

2条回答
  •  时光取名叫无心
    2020-12-01 04:22

    I was able to get this working, but it took some doing. I've pieced together the pertinent piece of code here:

    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
    
    UInt32 allowBluetoothInput = 1;
    AudioSessionSetProperty(
        kAudioSessionProperty_OverrideCategoryEnableBluetoothInput,
        sizeof (allowBluetoothInput),
        &allowBluetoothInput);
    

    It is also possible to which sources are available and switch between bluetooth, a headset, handset or the speakerphone but things become very involved at that point. The audio source manager I ultimately wrote was over 700 lines.

提交回复
热议问题