iosiphoneaudiospeakerspeakerphone

iOS 14.2 directs app audio output to ear speaker instead of bottom speaker


An app that I built has always output its audio through the bottom speaker (speakerphone), but it now outputs to the front (ear) speaker. I have not changed the app, so I assume the cause must be iOS 14.2, which I recently installed.

The app uses AVAudioSession, setting AVAudioSession.Category to .playAndRecord because it performs both audio recording and speech synthesis.

Any idea what 14.2 may have changed to cause this… and how I can specify that the output go to the bottom speaker?


Solution

  • It turns out that it was simply a matter of adding .defaultToSpeaker during setup:

    try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .defaultToSpeaker)

    I'm not sure why the option was only necessary beginning with iOS 14.2, but it solves the problem.