iOS 10.2 playback issue

215 views Asked by At

I have built a music-playing app. I added such code in my appdelegate and I have checked the box of Audio, AirPlay, and Picture in Picture in my project.

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; 

It works well in my iOS 8 and iOS 10 device in the background, but it doesn't work in iOS 10.2. I run my app in iOS 10.2, and play some audio from network, it won't play next after the last one has finished when I enter into the background or lock the screen.

After I go to foreground again, app received AVAudioSessionInterruptionNotification twice, and I log the user info of the notification which showed as first time AVAudioSessionInterruptionTypeKey = 1; and second time AVAudioSessionInterruptionOptionKey = 0;AVAudioSessionInterruptionTypeKey = 0;.

It‘s so odd that I doubt whether the iOS 10.2 bug about AVFoundation. How to fix it? Thanks very much.

0

There are 0 answers