---
title: "setMode(_:)"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avaudiosession/setmode(_:)"
---

# setMode(_:)

Sets the audio session’s mode.

## Declaration

```swift
func setMode(_ mode: AVAudioSession.Mode) throws
```

## Parameters

- `mode`: The audio session mode to apply to the audio session. See doc://com.apple.avfaudio/documentation/AVFAudio/AVAudioSession/Mode-swift.struct for supported mode values.

## Discussion

Discussion The audio session’s category and mode together define how your app uses audio. Typically, you set the category and mode before activating the session. You can also set the category or mode while the session is active, but doing so results in an immediate change. note: Instead of setting your category and mode properties independently, set them at the same time using the setCategory(_:mode:options:) or setCategory(_:mode:policy:options:) method.

## See Also

### Configuring standard audio behaviors

- [setCategory(_:mode:policy:options:)](avfaudio/avaudiosession/setcategory(_:mode:policy:options:).md)
- [setCategory(_:mode:options:)](avfaudio/avaudiosession/setcategory(_:mode:options:).md)
- [setCategory(_:options:)](avfaudio/avaudiosession/setcategory(_:options:).md)
- [setCategory(_:)](avfaudio/avaudiosession/setcategory(_:).md)
