User guide
Objective-CSwift
An audio session category is a key that identifies a set of audio behaviors for your app. By setting a category,
you indicate your audio intentions to the system—such as whether your audio should continue when the
Ringer/Silent switch is flipped. The seven audio session categories in iOS, along with a set of override and
modifier switches, let you customize your app’s audio behavior.
Each audio session category specifies a particular pattern of “yes” and “no” for each of the following behaviors,
as detailed in Table B-1 (page 47):
●
Interrupts non-mixable apps audio: If yes, non-mixable apps will be interrupted when your app activates
its audio session.
●
Silenced by the Silent switch: If yes, your audio is silenced when the user moves the Silent switch to silent.
(On iPhone, this switch is called the Ring/Silent switch .)
●
Supports audio input: If yes, app audio input (recording), is allowed.
●
Supports audio output: If yes, app audio output (playback), is allowed.
Most apps only need to set the category once, at launch. That said, you can change the category as often as
you need to, and can do so whether your session is active or inactive. If your session is inactive, the category
request is sent when you activate your session. If your session is already active, the category request is sent
immediately.
Choosing the Best Category
The precise behaviors associated with each category are not under your app’s control, but rather are set by
the operating system. Apple may refine category behavior in future versions of iOS. Your best strategy is to
pick the category that most accurately describes your intentions for the audio behavior you want. The appendix,
Audio Session Categories and Modes (page 47), summarizes behavior details for each category.
To pick the best category, consider:
●
Do you want to play audio, record audio, do both, or just perform offline audio processing?
2014-09-17 | Copyright © 2014 Apple Inc. All Rights Reserved.
18
Working with Categories