Instance Method

setCategory:withOptions:error:

Sets the audio session category with the specified options.

Declaration

- (BOOL)setCategory:(AVAudioSessionCategory)category withOptions:(AVAudioSessionCategoryOptions)options error:(NSError * _Nullable *)outError;

Parameters

category

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

options

A mask of additional options for handling audio. For a list of constants, see AVAudioSessionCategoryOptions

outError

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 audio session category and options were set successfully, or NO 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.

The behavior of certain categories can be tailored by specifying a mask of category options. Specifying an unsupported option for the indicated category results in an error. See AVAudioSessionCategoryOptions for category compatibility.

See Also

Configuring the Audio Session

category

The current audio session category.

- setCategory:error:

Sets the current audio session category.

- setCategory:mode:options:error:

Sets the audio session category, mode, and desired options.

availableCategories

The audio session categories available on the current device.

categoryOptions

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

mode

The current audio session mode.

- setMode:error:

Sets the audio session mode.

availableModes

The audio session modes available on the device.