Instance Method

setActive:withFlags:error:

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

Declaration

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

Parameters

active

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

flags

A bitmapped value containing one or more flags from the Activation Flags enumeration.

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

Returns YES on success or NO on failure.

Discussion

If another app’s active audio session has higher priority than your app, and that other audio session doesn’t allow mixing with other apps, attempting to activate your audio session might fail.

Topics

Constants

Activation Flags

Flags that provide additional information about your app’s audio intentions upon session activation or deactivation.

See Also

Activating the Audio Session

- setActive:error:

Activates or deactivates your app’s 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.