User guide

Objective-CSwift
An audio session is the intermediary between your app and iOS for configuring audio behavior. Upon launch,
your app automatically gets a singleton audio session. You configure it to express your apps audio intentions.
For example:
Will you mix your apps sounds with those from other apps (such as the Music app), or do you intend to
silence other audio?
How should your app to respond to an audio interruption, such as a Clock alarm?
How should your app respond when a user plugs in or unplugs a headset?
Audio session configuration influences all audio activity while your app is running, except for user-interface
sound effects played through the System Sounds Services API. You can query the audio session to discover
hardware characteristics of the device your app is on, such as channel count and sample rate. These
characteristics can vary by device and can change according to user actions while your app runs.
You can explicitly activate and deactivate your audio session. For app sound to play, or for recording to work,
your audio session must be active. The system can also deactivate your audio session—which it does, for
example, when a phone call arrives or an alarm sounds. Such a deactivation is called an interruption. The audio
session APIs provide ways to respond to and recover from interruptions.
Audio Session Default Behavior
An audio session comes with some default behavior. Specifically:
Playback is enabled, and recording is disabled.
When the user moves the Silent switch (or Ring/Silent switch on iPhone) to the silent” position, your audio
is silenced.
When the user presses the Sleep/Wake button to lock the screen, or when the Auto-Lock period expires,
your audio is silenced.
When your audio starts, other audio on the device—such as Music app audio that was already playing—is
silenced.
2014-09-17 | Copyright © 2014 Apple Inc. All Rights Reserved.
10
Defining an Audio Session