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 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 session’s active state was changed successfully, or NO if it was not.

Discussion

If another active audio session has higher priority than yours (for example, 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 will stop the running audio objects, deactivate the session, and a AVAudioSessionErrorCodeIsBusy error will be returned.

See Also

Activating the Audio Session

- setActive:withOptions:error:

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

- activateWithOptions:completionHandler:

Asynchronously activates an audio session on watchOS.

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