For some reason, my voice recorder app won't use AirPods as an input source. Upon beginning a recording, the input source changes from the AirPods to the iPhone microphone. Not sure how to fix it.
Asked
Active
Viewed 5,515 times
4
-
What audio session category and mode have you set? Reference: https://developer.apple.com/reference/audiotoolbox/audio_session_services/1618427-audio_session_categories – Mark Mar 17 '17 at 20:26
-
Hey Eddie, was just checking in to see if you were able to sort this out. We've recently encountered the same issue but have not been able to determine what is missing either. – djneely Jul 10 '17 at 19:23
4 Answers
8
There are two ways to record and play audio while AirPods are connected. For both cases we will use AVAudioSessionCategoryPlayAndRecord
category. The trick is to manage AVAudioSession
s option set.
- Add
.allowBluetoothA2DP
option. This will allow you to listen audio via AirPods and record with internal mic. - Add
.allowBluetooth
option. With this option you can record audio with AirPods during playback. But in this case audio quality will be reduced.

Timur Bernikovich
- 5,660
- 4
- 45
- 58
1
Eddie, If you're still having the issue, please see a similar post I made that we were able to finally resolve the issues we were having.

djneely
- 1,074
- 13
- 25
0
Firstly i catch available output source.
let currentOutputSource = AVAudioSession.sharedInstance().outputDataSource
try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: [.allowBluetooth, .allowBluetoothA2DP])
if let currentOutputSource = currentOutputSource {
// Then i set known output source to input source.
try AVAudioSession.sharedInstance().setInputDataSource(currentOutputSource)
}
try? AVAudioSession.sharedInstance().setActive(true)

Vitaliy
- 25
- 3
-1
It is worked for me
try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: [.allowBluetooth, .allowBluetoothA2DP]
if let headphones = AVAudioSession.sharedInstance().availableInputs?.first(where: { $0.portType == .bluetoothHFP || $0.portType == .bluetoothA2DP || $0.portType == .headphones }) {
try? AVAudioSession.sharedInstance().setPreferredInput(headphones)
}
try? AVAudioSession.sharedInstance().setActive(true)

Vitaliy
- 25
- 3