Contents

setActive(_:options:)

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

Declaration

func setActive(_ active: Bool, options: AVAudioSession.SetActiveOptions = []) throws

Parameters

  • active:

    Specify True to activate your app’s audio session, or False to deactivate it.

  • options:

    An integer bit mask containing one or more constants from the Setactiveoptions enumeration.

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.

Topics

Data Types

See Also

Activating the audio configuration