Type Property

defaultToSpeaker

Determines whether audio from the session defaults to the built-in speaker instead of the receiver.

Declaration

static var defaultToSpeaker: AVAudioSession.CategoryOptions { get }

Discussion

This option can only be set when using the playAndRecord category. It's used to modify the category's routing behavior so that audio will always route to the speaker rather than receiver if no other accessory, such as headphones, are in use.

When using this option, user gestures will be honored. For example, plugging in a headset will cause the route to change to headset mic/headphones and unplugging the headset will cause the route to change to built-in mic/speaker (as opposed to built-in mic/receiver) when this override has been set.

In the case of using a USB input-only accessory, audio input would come from the accessory and output would route to headphones (if attached) or speaker if headphones are not plugged in. The use case is simply to route audio to speaker instead of receiver in cases where the audio would normally go to the receiver.