Audio not playing on device if AVAudioSession MixWithOthers is set to yes

1k views Asked by At

I'm trying to create a music app with background playing, so I've defined the AVAudioSession with category AVAudioSessionCategoryPlayback in my delegate didFinishLaunchingWithOptions.

Because I want the music to not being interrupted by other audio while in background, I did set AVAudioSessionCategoryOptionMixWithOthers as option to the session, so my code is:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];

This works perfectly on my device (an iPad 2 with iOS 8.3), on all the simulators, etc. but when I play it on an iPhone 4S with iOS 7.1.2 it won't play audio at all. It's not that it interrupts when i play other audio - it just won't play at all.

If I remove the MixWithOthers thing, audio works perfectly - but I need it to mix or duck, and ducking doesn't work either. I've tried deactivating the AVAudioSession first but that doesn't work either.

Have any of you had this problem before? I've tried anything I could imagine but nothing works.

0

There are 0 answers