AVAudioSession not interrupted other music apps

I have developed an app which needs to play sound in the background. I use AVAudioPlayer to play the sound. But when the audio starts to play in the background and another app running on the background (Music App) is didn't stop, Both apps are playing parallel (both audio mixing).


How can I interrupt another music app to in the background?


I used following code to interrupted


self.audioSession = [AVAudioSession sharedInstance];

[self.audioSession setCategory:AVAudioSessionCategoryAmbient withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];

[self.audioSession setMode:AVAudioSessionModeDefault error:&error];

[self.audioSession setActive:YES error:&error];


But this doesn't work for me.


Thank you.