Structure

AVAudioSession.Category

Audio session category identifiers.

Declaration

struct Category

Overview

An audio session category defines a set of audio behaviors. The operating system sets the precise behaviors associated with each category, and Apple may refine category behavior in future versions of the operating system. Choose the category that most accurately describes the audio behavior you want.

You can refine the configuration provided by the playback, record, and playAndRecord categories by using an audio session mode, as described in AVAudioSession.Mode.

Supporting AirPlay

The audio session playback-only categories (ambient, soloAmbient, and playback) support both the mirrored and nonmirrored variants of AirPlay.

The audio session category playAndRecord supports only the mirrored variant of AirPlay, while the record and multiRoute categories don’t allow routing to AirPlay.

Topics

Audio Session Categories

static let ambient: AVAudioSession.Category

The category for an app in which sound playback is nonprimary—that is, your app also works with the sound turned off.

static let multiRoute: AVAudioSession.Category

The category for routing distinct streams of audio data to different output devices at the same time.

static let playAndRecord: AVAudioSession.Category

The category for recording (input) and playback (output) of audio, such as for a Voice over Internet Protocol (VoIP) app.

static let playback: AVAudioSession.Category

The category for playing recorded music or other sounds that are central to the successful use of your app.

static let record: AVAudioSession.Category

The category for recording audio; this category silences playback audio.

static let soloAmbient: AVAudioSession.Category

The default audio session category.

static let audioProcessing: AVAudioSession.Category

The category for using an audio hardware codec or signal processor while not playing or recording audio.

Deprecated

Relationships

See Also

Configuring the Audio Session

var category: AVAudioSession.Category

The current audio session category.

func setCategory(AVAudioSession.Category)

Sets the audio session’s category.

var availableCategories: [AVAudioSession.Category]

The audio session categories available on the current device.

var categoryOptions: AVAudioSession.CategoryOptions

The set of options associated with the current audio session category.

func setCategory(AVAudioSession.Category, options: AVAudioSession.CategoryOptions)

Sets the audio session’s category with the specified options.

struct AVAudioSession.CategoryOptions

Constants that specify optional audio behaviors.

var mode: AVAudioSession.Mode

The current audio session’s mode.

func setMode(AVAudioSession.Mode)

Sets the audio session’s mode.

var availableModes: [AVAudioSession.Mode]

The audio session modes available on the device.

struct AVAudioSession.Mode

Audio session mode identifiers.

enum AVAudioSession.RouteSharingPolicy

Cases that indicate the possible route-sharing policies for an audio session.