我的 iOS6 和将蓝牙设置为输出的工作代码:
// create and set up the audio session
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory: AVAudioSessionCategoryPlayAndRecord error: nil];
[audioSession setActive: YES error: nil];
// set up for bluetooth microphone input
UInt32 allowBluetoothInput = 1;
OSStatus stat = 0;
stat = AudioSessionSetProperty (
kAudioSessionProperty_OverrideCategoryEnableBluetoothInput,
sizeof (allowBluetoothInput),
&allowBluetoothInput
);
自 iOS7 起,AudioSessionSetProperty 方法已被弃用。遵循此线程如何在不使用 AudioSessionSetProperty 的情况下将音频路由到扬声器?您可以将输出更改为 AVAudioSessionPortOverrideSpeaker 或 AVAudioSessionPortOverrideNone 但此处没有蓝牙选项。
我的实际目标是支持不使用 A2DP 而是使用 HFP 的蓝牙设备。
那么如何在不使用不推荐使用的方法的情况下实现这一点呢?