AVAudioRecorder/AVAudioSession with Apple Airpods

巧了我就是萌 提交于 2019-11-29 07:37:59

Turns out the issue we were having had to do with the category that was being set. Due to issues we were having with various Bluetooth output devices we set and keep the audio category set to AVAudioSessionCategoryPlayback except when we're ready to record.

Per this Stack post: AVAudioSession: Some Bluetooth devices are not working properly on my App

In the above code we switch the category over to AVAudioSessionCategoryRecord before we're about to record. While this works for the builtin mics and other bluetooth devices it did not work with AirPods. Instead, setting the category to AVAudioSessionCategoryPlayAndRecord allows recording to work with the AirPods.

I then still maintain a Playback only category for the session throughout the app for audio playback. Only switching to PlayAndRecord when about to record audio.

As a side note: Apple does not list the AirPods as an MFi device. https://mfi.apple.com/MFiWeb/getFAQ.action#1-1

I think AirPods are MFI (Made For Iphone) accessories which means that bluetooth communication goes thru ExternalAccessory framework https://developer.apple.com/documentation/externalaccessory

Here is apple demo: https://developer.apple.com/library/content/samplecode/EADemo/Introduction/Intro.html

Tip: Protocol name must be put in Info.plist in UISupportedExternalAccessoryProtocols key

More details: https://mfi.apple.com/MFiWeb/getFAQ.action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!