Instance Method


Temporarily changes the current audio route.


- (BOOL)overrideOutputAudioPort:(AVAudioSessionPortOverride)portOverride error:(NSError * _Nullable *)outError;



The override option for audio output. For a list of constants, see AVAudioSessionPortOverride.


On input, a pointer to an error object. If an error occurs, the pointer is set to an NSError object that describes the error. If you do not want error information, pass in nil.

Return Value

YES if the new audio routing option was set successfully, or NO if it was not.


If your app uses the AVAudioSessionCategoryPlayAndRecord category, calling this method with the AVAudioSessionPortOverrideSpeaker option causes audio to be routed 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 AVAudioSessionPortOverrideNone option.

If you would prefer to permanently enable this behavior, you should instead set the category's AVAudioSessionCategoryOptionDefaultToSpeaker option. Setting this option will always route to the speaker rather than receiver if no other accessory such as headphones are in use.


Data Types

See Also

Working with Audio Routes


An object describing the current audio input and output route.


A Boolean value indicating whether an audio input path is available.


An array of input ports available for routing.


The preferred input port for audio routing.

- setPreferredInput:error:

Sets the preferred input port for audio routing.


An array of available data sources for the audio session’s current input port.


The currently selected input data source.

- setInputDataSource:error:

Selects a data source for the audio session’s current input port.


An array of available output data sources for the current audio route.


The currently selected output data source.

- setOutputDataSource:error:

Sets the output data source for an audio session.


The current routing policy.

- setCategory:mode:routeSharingPolicy:options:error:

Sets the session category, mode, route sharing policy, and options.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software