I've set up an AVCaptureSession and AVAudiEngine to record video and audio. I am playing the result with AVPlayer, which is working fine except that there is an audio issue.
The issue is only present on my iPhone, the iPad is working fine (probably because it does not have a receiver). The issue is that when I set my AVAudioSession like this:
do {
try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: [.defaultToSpeaker])
try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation)
} catch {
NSLog(logPrefix + "Could not set the category.")
}
The audio comes out from both receiver AND speaker, which is barely audible. If I omit the options, the audio just comes out of the receiver (as expected). If I include a mode (voiceChat or videoChat), iPad does not like it (the sample rate is not synced).
Is there a trick you know to make it play loudly on the speaker?