iOS SDK: How do I dim/duck audio coming from other apps instead of stopping them during a call?

Options

I want to allow music from another app to play while the user is in a call.

The current behavior is that when a call is started, all other audio is paused until the call is completed.

Instead, I want the app to continue playing other background audio and "duck" (i.e. turn down the volume on background audio) when audio is being received from the call.

How can I do this?

I tried to set the following to allow both audio to play, but it didn't work; it seems like Daily is overriding these settings somewhere?

import AVFoundation

//On app startup.
do {
try AVAudioSession.sharedInstance().setCategory(.ambient)
try AVAudioSession.sharedInstance().setActive(true)
} catch {
print("Failed to set audio session category. \(error)")
}

Tagged: