Instance Method


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


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



Specify true to activate your app’s audio session, or false to deactivate it.


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

Return Value

true if the session’s active state was changed successfully, or false if it was not.


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 AVAudioSession.ErrorCode.isBusy error will be returned.


Data Types

struct AVAudioSession.SetActiveOptions

A flag that provides additional information about your app’s audio intentions upon session deactivation.

See Also

Activating the Audio Session