Contents

interruptSpokenAudioAndMixWithOthers

An option that determines whether to pause spoken audio content from other sessions when your app plays its audio.

Declaration

static var interruptSpokenAudioAndMixWithOthers: AVAudioSession.CategoryOptions { get }

Discussion

You can set this option only if the audio session category is playAndRecord, playback, or multiRoute. Setting this option also sets mixWithOthers.

If you clear this option, audio from your audio session interrupts other sessions. If you set this option, the system mixes your audio with other audio sessions, but interrupts (and stops) audio sessions that use the spokenAudio audio session mode. It pauses the audio from other apps as long as your session is active. After your audio session deactivates, the system resumes the interrupted app’s audio.

Set this option if your app’s audio is occasional and spoken, such as in a turn-by-turn navigation app or an exercise app. This avoids intelligibility problems when two spoken audio apps mix. If you set this option, also set the duckOthers option unless you have a specific reason not to. Ducking other audio, rather than interrupting it, is appropriate when the other audio isn’t spoken audio.

When you configure your audio session category using this option, notify other apps on the system when you deactivate your session so that they can resume audio playback. To do so, deactivate your session using the notifyOthersOnDeactivation option.

do {
    try session.setActive(false, options: .notifyOthersOnDeactivation)
} catch let error as NSError {
    print("Failed to deactivate audio session: \(error.localizedDescription)")
}

See Also

Category options