AVAudioSession.SetActive Method

Definition

Overloads

SetActive(Boolean)

Activates or deactivates the audio session for the application.

SetActive(Boolean, AVAudioSessionSetActiveOptions)

Activates and deactivates the audio session for the application.

SetActive(Boolean, NSError)

Activates or deactivates the audio session for the application.

SetActive(Boolean, AVAudioSessionFlags, NSError)

Application developers should not use this deprecated method.

SetActive(Boolean, AVAudioSessionSetActiveOptions, NSError)

Activates and deactivates the audio session for the application.

SetActive(Boolean)

Activates or deactivates the audio session for the application.

public Foundation.NSError SetActive (bool beActive);
member this.SetActive : bool -> Foundation.NSError

Parameters

beActive
Boolean

Set to true to activate audio, false to deactivate it.

Returns

null on success, or an instance of NSError on failure.

Remarks

Audio activation can fail if an application with a higher audio priority than yours is currently running.

Audio deactivation can fail if there are running audio operations in progress (playback, recording, audio queues or conversions).

Applies to

SetActive(Boolean, AVAudioSessionSetActiveOptions)

Activates and deactivates the audio session for the application.

public Foundation.NSError SetActive (bool active, AVFoundation.AVAudioSessionSetActiveOptions options);
member this.SetActive : bool * AVFoundation.AVAudioSessionSetActiveOptions -> Foundation.NSError

Parameters

active
Boolean

Set to true to activate audio, false to deactivate it.

options
AVAudioSessionSetActiveOptions

Options to control the audio activation.

Returns

null on success, or an instance of NSError on failure.

Remarks

Audio activation can fail if an application with a higher audio priority than yours is currently running.

Audio deactivation can fail if there are running audio operations in progress (playback, recording, audio queues or conversions).

Applies to

SetActive(Boolean, NSError)

Activates or deactivates the audio session for the application.

[Foundation.Export("setActive:error:")]
public virtual bool SetActive (bool beActive, out Foundation.NSError outError);
abstract member SetActive : bool *  -> bool
override this.SetActive : bool *  -> bool

Parameters

beActive
Boolean

Set to true to activate audio, false to deactivate it.

outError
NSError

On failure, this contains the error details.

Returns

true on success, false on error. If there is an error the outError parameter contains the new instance of NSError describing the problem.

Attributes

Remarks

Audio activation can fail if an application with a higher audio priority than yours is currently running.

Audio deactivation can fail if there are running audio operations in progress (playback, recording, audio queues or conversions).

Applies to

SetActive(Boolean, AVAudioSessionFlags, NSError)

Application developers should not use this deprecated method.

[Foundation.Export("setActive:withFlags:error:")]
[ObjCRuntime.Deprecated(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, "Use 'SetActive (bool, AVAudioSessionSetActiveOptions, out NSError)' instead.")]
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.TvOS, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual bool SetActive (bool beActive, AVFoundation.AVAudioSessionFlags flags, out Foundation.NSError outError);
abstract member SetActive : bool * AVFoundation.AVAudioSessionFlags *  -> bool
override this.SetActive : bool * AVFoundation.AVAudioSessionFlags *  -> bool

Parameters

beActive
Boolean
outError
NSError

On failure, this contains the error details.

Returns

true if the request was successful, otherwise the outError parameter contains an instance of NSError describing the problem.

Attributes

Applies to

SetActive(Boolean, AVAudioSessionSetActiveOptions, NSError)

Activates and deactivates the audio session for the application.

[Foundation.Export("setActive:withOptions:error:")]
[ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 6, 0, ObjCRuntime.PlatformArchitecture.All, null)]
public virtual bool SetActive (bool active, AVFoundation.AVAudioSessionSetActiveOptions options, out Foundation.NSError outError);
abstract member SetActive : bool * AVFoundation.AVAudioSessionSetActiveOptions *  -> bool
override this.SetActive : bool * AVFoundation.AVAudioSessionSetActiveOptions *  -> bool

Parameters

active
Boolean

Set to true to activate audio, false to deactivate it.

options
AVAudioSessionSetActiveOptions

Options to control the audio activation.

outError
NSError

On failure, this contains the error details.

Returns

true if the request was successful, otherwise the outError parameter contains an instance of NSError describing the problem.

Attributes

Remarks

Audio activation can fail if an application with a higher audio priority than yours is currently running.

Audio deactivation can fail if there are running audio operations in progress (playback, recording, audio queues or conversions).

Applies to