Instance Method

setCategory(_:mode:policy:options:)

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

Declaration

func setCategory(_ category: AVAudioSession.Category, mode: AVAudioSession.Mode, policy: AVAudioSession.RouteSharingPolicy, options: AVAudioSession.CategoryOptions = []) throws

Discussion

Options are used only with a default routing policy. With a long-form route sharing policy, you can use the following values:

  • Categories: playback

  • Modes: default, moviePlayback, spokenAudio

See Also

Working with Audio Routes

var currentRoute: AVAudioSessionRouteDescription

An object describing the current audio input and output route.

var isInputAvailable: Bool

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

var availableInputs: [AVAudioSessionPortDescription]?

An array of input ports available for routing.

var preferredInput: AVAudioSessionPortDescription?

The preferred input port for audio routing.

func setPreferredInput(AVAudioSessionPortDescription?)

Sets the preferred input port for audio routing.

var inputDataSources: [AVAudioSessionDataSourceDescription]?

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

var inputDataSource: AVAudioSessionDataSourceDescription?

The currently selected input data source.

func setInputDataSource(AVAudioSessionDataSourceDescription?)

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

var outputDataSources: [AVAudioSessionDataSourceDescription]?

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

var outputDataSource: AVAudioSessionDataSourceDescription?

The currently selected output data source.

func setOutputDataSource(AVAudioSessionDataSourceDescription?)

Sets the output data source for an audio session.

func overrideOutputAudioPort(AVAudioSession.PortOverride)

Temporarily changes the current audio route.