Audio session interruptions (iOS)


The Unity Integration supports two audio session categories.

  • AkAudioSessionCategorySoloAmbient (Default): When you use this category, audio from other apps is silenced. Your app's audio is also silenced by screen locking and by the Silent switch (called the Ring/Silent switch on the iPhone).
  • AkAudioSessionCategoryAmbient: AmbientSound allows your app's audio to be mixed with other apps. Any audio interruptions, such as an incoming phone call, or playing music with the Music app using a remote control, will be mixed with your app's audio by default. However, you can specify route sounds and music to a special buss so that they get muted when user music plays and unmuted when user music stops. The muting and unmuting are done by the sound engine internally. You can still define a source-change callback to respond to user music behaviors for other useful tasks, such as updating a UI element to notify users of the user music playback status.

Using both categories, an audio interruption, such as a phone call, will seize the audio session from your app. The necessary audio session management is done internally by the sound engine. However, the app may perform other tasks such as UI updates to notify user of the interruptions. To achieve this, the app need to specify an interruption listener callback function to respond to the events of entering and exiting the audio interruption. In the case of user music, another dedicated callback source-change callback can be defined to respond to the events of stopping the user music. The proper pause and resume actions on playing sounds are handled by the sound engine internally.

Playing user music using the remote-control will trigger an interruption (under the SoloAmbient category) or a special source-change event (under the Ambient category), however, stopping user music using the remote-control will trigger a source-change under all categories. Again, the sound engine takes care of all the audio pipeline tasks regarding such events. The app can register a source-change callback to respond to these events if extra work is needed.

The callback and the remote control

Unlike phone calls and clock alarms, which trigger the interruption callback at both the start and the end of an interruption, the remote control only triggers the callback when the interruption starts. Furthermore, the iOS SDK provides no means to differentiate between the interruption sources. To handle all types of interruptions under the SoloAmbientSound category, you need to resort to your app's UI to guide your users to restore the app's audio, with the help of the interruption listener callback.

The procedure

  1. Ensure Unity's built-in audio is disabled. Check in the menu Edit > Project Settings > Audio, option Disable Audio.
  2. (Optional) Add a callback based on the prototype AkCallbackManager.AudioInterruptionCallback(), and use AkCallbackManager.SetInterruptionCallback() to register it.
  3. (Optional) Add a callback based on the prototype AkCallbackManager.AudioSourceChangeCallback(), and use AkCallbackManager.SetSourceChangeCallback() to register it.
Generated on Tue Aug 23 02:44:59 2016 for Wwise Unity Integration by  doxygen 1.6.3