overrideOutputAudioPort(_:)
Temporarily changes the current audio route.
Declaration
func overrideOutputAudioPort(_ portOverride: AVAudioSession.PortOverride) throwsParameters
- portOverride:
The override option for audio output. For a list of constants, see Portoverride.
Discussion
If your app uses the playAndRecord category, calling this method with the AVAudioSession.PortOverride.speaker option causes the system to route audio to the built-in speaker and microphone regardless of other settings. This change remains in effect only until the current route changes or you call this method again with the AVAudioSession.PortOverride.none option.
If you’d prefer to permanently enable this behavior, you should instead set the category’s defaultToSpeaker option. Setting this option routes to the speaker rather than the receiver if no other accessory such as headphones are in use.