User guide

AVAudioSessionModeVideoChat
AVAudioSessionModeGameChat
Fine-Tuning a Category
You can fine-tune an audio session category in a variety of ways. Depending on the category, you can:
Allow other audio (such as from the Music app) to mix with yours when a category normally disallows it
Change the audio output route from the receiver to the speaker if no other route is available
Specify that other audio should reduce in volume (“duck”) when your audio session is active
You can override the interruption characteristic of the AVAudioSessionCategoryPlayback,
AVAudioSessionCategoryPlayAndRecord, and AVAudioSessionCategoryMultiRoute categories so
that other audio is allowed to mix with yours. To perform the override, apply the
AVAudioSessionCategoryOptionMixWithOthers property to your audio session. When you set your app
to be mixable, your app will not interrupt audio from other non-mixable apps when its audio session goes
active. Also, your apps audio will not be interrupted by another app’s non-mixable audio session, for example
the Music app.
You can programmatically influence the audio output route. When using the
AVAudioSessionCategoryPlayAndRecord category, audio normally goes to the receiver (the small speaker
you hold to your ear when on a phone call). You can redirect audio to the speaker at the bottom of the phone
by using the overrideOutputAudioPort:error: method.
Finally, you can enhance a category to automatically lower the volume of other audio when your audio is
playing. This could be used, for example, in an exercise app. Say the user is exercising along to the Music app
when your app wants to overlay a verbal message—for instance, “You’ve been rowing for 10 minutes.” To
ensure that the message from your app is intelligible, apply the
AVAudioSessionCategoryOptionDuckOthers property to your audio session. When ducking takes place,
all other audio on the device—apart from phone audio—lowers in volume. Apps that use ducking must manage
their sessions activation state. Activate the audio session prior to playing the audio and deactivate the session
after playing the audio.
Working with Categories
Fine-Tuning a Category
2014-09-17 | Copyright © 2014 Apple Inc. All Rights Reserved.
24