User guide
The system has final authority to activate or deactivate any audio session present on a device. The system
follows the inviolable rule that “the phone always wins.” No app, no matter how vehemently it demands priority,
can trump the phone. When a call arrives, the user gets notified and your app is interrupted—no matter what
audio operation you have in progress and no matter what category you have set.
Incorporating an AVCaptureSession
The AV Foundation capture APIs (AVCaptureDevice, AVCaptureSession) enable you to capture synchronized
audio and video from camera and microphone inputs. As of iOS 7, the AVCaptureDevice object that represents
microphone input can share your app’s AVAudioSession. By default, AVCaptureSession will configure
your AVAudioSession optimally for recording when your AVCaptureSession is using the microphone. Set
the automaticallyConfiguresApplicationAudioSession property to NO to override the default
behavior and the AVCaptureDevice will use your current AVAudioSession settings without altering them.
See AVCaptureSession Class Reference and the Media Capture chapter for more information.
Initializing Your Audio Session
The system provides an audio session object upon launch of your app. However, you must initialize the session
in order to handle interruptions.
The AV Foundation framework for managing interruptions takes advantage of the implicit initialization that
occurs when you obtain a reference to the AVAudioSession object, as shown here:
// implicitly initializes your audio session
AVAudioSession *session = [AVAudioSession sharedInstance];
The session variable now represents the initialized audio session and can be used immediately. Apple
recommends implicit initialization when you handle audio interruptions with the AVAudioSession class’s
interruption notifications, or with the delegate protocols of the AVAudioPlayer and AVAudioRecorder
classes.
Defining an Audio Session
Incorporating an AVCaptureSession
2014-09-17 | Copyright © 2014 Apple Inc. All Rights Reserved.
14