Instance Method

setCategory:mode:routeSharingPolicy:options:error:

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

Declaration

- (BOOL)setCategory:(AVAudioSessionCategory)category mode:(AVAudioSessionMode)mode routeSharingPolicy:(AVAudioSessionRouteSharingPolicy)policy options:(AVAudioSessionCategoryOptions)options error:(NSError * _Nullable *)outError;

Parameters

category

The category to apply to the audio session. SeeAVAudioSessionCategory for supported category values.

mode

The audio session mode to apply to the audio session. For a list of values, see AVAudioSessionMode.

policy

The route-sharing policy to apply to the audio session. For a list of values, see AVAudioSessionRouteSharingPolicy.

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 an NSError object that describes the error. If you don’t want error information, pass in nil.

Discussion

You specify options only with a default routing policy. With a long-form route-sharing policy, you can use the AVAudioSessionCategoryPlayback category and the AVAudioSessionModeDefault, AVAudioSessionModeMoviePlayback, and AVAudioSessionModeSpokenAudio modes.

See Also

Configuring the Audio Session

category

The current audio session category.

- setCategory:error:

Sets the audio session’s category.

availableCategories

The audio session categories available on the current device.

AVAudioSessionCategory

Audio session category identifiers.

categoryOptions

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

- setCategory:withOptions:error:

Sets the audio session’s category with the specified options.

AVAudioSessionCategoryOptions

Constants that specify optional audio behaviors.

mode

The current audio session’s mode.

- setMode:error:

Sets the audio session’s mode.

- setCategory:mode:options:error:

Sets the audio session’s category, mode, and options.

availableModes

The audio session modes available on the device.

AVAudioSessionMode

Audio session mode identifiers.

routeSharingPolicy

The current route-sharing policy.

AVAudioSessionRouteSharingPolicy

Cases that indicate the possible route-sharing policies for an audio session.