I am trying to play a "ding" sound over an audio track.
When setting up the player, we have:
try AVAudioSession.sharedInstance()
.setCategory(.playback,
mode: .default,
policy: .longFormAudio,
options: [])
try AVAudioSession.sharedInstance().setActive(true)
Then later on, a user action (e.g. tapping) does:
AudioServicesPlaySystemSound(SystemSoundID(1407))
This works well. The only issue is that the playing track gets ducked to play the system sound.
How can I prevent this from happening?
Strangely, in XCode simulator, the tracks play in parallel and no ducking occurs.
Update: updating to this has no effect:
try AVAudioSession.sharedInstance()
.setCategory(.playback,
mode: .default,
policy: .longFormAudio,
options: .mixWithOthers)