在iOS中通过蓝牙播放时从内置麦克风录制 [英] Recording from Built-In Mic when Playing through Bluetooth in iOS
问题描述
是否可以从iPhone的内置麦克风接收音频输入,同时通过蓝牙耳机播放音频?
Is it possible to receive audio input from iPhone's built-in microphone, and play that audio through a Bluetooth headset, at the same time?
我的目标是即使输出设备是耳机,也总是使用内置麦克风作为输入设备,因为内置麦克风在我的使用情况下更方便。
My goal is to always use the built-in microphone as the input device, even if the output device is a headset, because the built-in microphone is more convenient in my use cases.
当输出设备是有线耳机时,我知道如何实现我的目标,就像与iPhone捆绑的耳机一样。我只需插入有线耳机,然后调用以下方法:
I know how to achieve my goal when the output device is a wired headset, like the one that comes bundled with an iPhone. I simply plug the wired headset in, and call the following method:
- (void)selectBuiltInMicrophone
{
AVAudioSession *session = [AVAudioSession sharedInstance];
for (AVAudioSessionPortDescription *port in session.availableInputs)
if ([port.portType isEqualToString:AVAudioSessionPortBuiltInMic]) {
NSError *error;
[session setPreferredInput:port error:&error];
break;
}
}
通过调用上述方法,输入设备将是从有线耳机的麦克风切换到iPhone的内置麦克风,而输出设备不受影响,因此iPhone将从内置麦克风录制并通过有线耳机播放。这就是我的期望。
By calling the above method, the input device will be switched from the wired headset's microphone to iPhone's built-in microphone, while the output device remains unaffected, so the iPhone will record from the built-in microphone and play through the wired headset. This is what I expect.
问题是,当耳机是蓝牙耳机时,此方法不起作用。如果我将蓝牙耳机连接到iPhone,然后调用上面的方法,内置麦克风将成为输入设备,这很棒,但输出设备也将更改为iPhone的接收器,这是不好的。
The problem is, this method does not work when the headset is a Bluetooth one. If I connect a Bluetooth headset to the iPhone, then call the above method, the built-in microphone will becomes the input device, which is great, but the output device will also be changed to iPhone's receiver, which is bad.
似乎蓝牙耳机的输入和输出被锁定在一起:您要么同时使用它们,要么不使用它们。我的目标真的不可能吗?或者有一种方法可以克服明显的限制?
It seems that the input and the output of a Bluetooth headset are locked together: you either use both of them, or you use none of them. Is my goal really impossible? Or there exists a way to overcome the apparent limitation?
推荐答案
无法从iPhone内置接收音频输入-in麦克风,同时通过蓝牙耳机播放音频
- 您可以预防像 walkie-talkie 一样使用。
- 你必须创建两个会话。意味着在录制音频时你必须启用带有记录和播放的音频会话。
- 播放时你必须将选项设置为音频(允许蓝牙)。
- 虽然录制您必须设置记录和播放。
- There is a prevention that you can use like a walkie-talkie .
- you have to create Two sessions . Means while recording audio you have to enable audio session with recordandplay.
- while Playing you have to set the option to audiosession (allowingBluetooth) .
- While Recording You have to set recordandplay.
这篇关于在iOS中通过蓝牙播放时从内置麦克风录制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!