Instance Method

setCategory(_:)

Sets the current audio session category.

Declaration

func setCategory(_ category: AVAudioSession.Category) throws

Parameters

category

The audio session category to apply to the audio session. See Audio Session Categories for supported category values.

Return Value

true if the audio session category and options were set successfully, or false otherwise.

Discussion

The audio session's category defines how the app intends to use audio. Typically, you set the category before activating the session. You can also set the category while the session is active, but this results in an immediate route change.

See Also

Configuring the Audio Session

var category: AVAudioSession.Category

The current audio session category.

func setCategory(AVAudioSession.Category, options: AVAudioSession.CategoryOptions)

Sets the audio session category with the specified options.

var availableCategories: [AVAudioSession.Category]

The audio session categories available on the current device.

var categoryOptions: AVAudioSession.CategoryOptions

The mask of options associated with the current audio session category.

var mode: AVAudioSession.Mode

The current audio session mode.

func setMode(AVAudioSession.Mode)

Sets the audio session mode.

var availableModes: [AVAudioSession.Mode]

The audio session modes available on the device.

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