AVAudioRecorder/AVAudioSession with Apple Airpods

后端 未结 2 498
南旧
南旧 2020-12-17 01:49

I see the question already asked here:

AirPods not working as an input source for Voice Recorder App

I\'ve checked in with this thread but no response.

相关标签:
2条回答
  • 2020-12-17 02:25

    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

    0 讨论(0)
  • 2020-12-17 02:38

    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

    0 讨论(0)
提交回复
热议问题