Contents

setActive:error:

Activates or deactivates your app’s audio session.

Declaration

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

Parameters

  • active:

    Use True to activate your app’s audio session, or False 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

true if the system successfully changed the active state; otherwise false.

Discussion

Your app may activate a session with category playback when another app is hosting a call, for example to start a SharePlay activity. However, your app isn’t permitted to capture the microphone of the active call.

The session fails to activate if another audio session has higher priority than yours (such as a phone call) and neither audio session allows mixing. Deactivating an audio session with running audio objects stops the objects, makes the session inactive, and returns an AVAudioSession.ErrorCode.isBusy error.

When your app deactivates a session, the return value is false but the active state changes to deactivate.

See Also

Activating the audio configuration