---
title: "setActive(_:withFlags:)"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avaudiosession/setactive(_:withflags:)"
---

# setActive(_:withFlags:)

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

## Declaration

```swift
func setActive(_ active: Bool, withFlags flags: Int) throws
```

## Parameters

- `active`: Use doc://com.apple.documentation/documentation/Swift/true to activate your app’s audio session or doc://com.apple.documentation/documentation/Swift/false to deactivate it.
- `flags`: A bitmapped value containing one or more flags.

## Discussion

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.
