Instance Method

setActive:error:

Activates or deactivates your app’s audio session.

Declaration

- (BOOL)setActive:(BOOL)active error:(NSError * _Nullable *)outError;

Parameters

active

Use YES to activate your app’s audio session, or NO to deactivate it.

outError

On input, a pointer to an error object. If an error occurs, the framework sets the pointer to an NSError object that describes the error. If you don’t want error information, pass in nil.

Return Value

YES if the session’s active state was changed successfully, or NO if it was not.

Discussion

If another audio session has higher priority than yours (such as a phone call), and neither audio session allows mixing, attempting to activate your audio session fails. Deactivating an audio session that has running audio objects stops them, deactivates the session, and returns an AVAudioSessionErrorCodeIsBusy error.

See Also

Activating the Audio Session

- setActive:withOptions:error:

Activates or deactivates your app’s audio session using the specified options.

- activateWithOptions:completionHandler:

Activates an audio session asynchronously on watchOS.

- setActive:withFlags:error:

Activates or deactivates your app’s audio session; provides flags for use by other audio sessions.

Deprecated