Background audio not working with Xcode 7

会有一股神秘感。 提交于 2019-12-09 23:14:41

问题


I have a radio player app, which streams audio from online radio stations. I have background modes enabled, like so:

When I built the app with Xcode 6, it worked on all devices and all iOS versions up to iOS 8. It even worked on an iPhone 6 that was later updated to iOS 9. Since then, I have updated to Xcode 7 and now when I build and run it on any device with any iOS version the background audio does not work, it just stops when the app goes to background.

Any ideas?


回答1:


In your plist make sure where it says "Application does not run in background" is NO.

Then add the following Code to your your appDelegate.m file in didFinishLaunchingWithOptions Method.

NSError *sessionError = nil;

NSError *activationError = nil;

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:&sessionError];

[[AVAudioSession sharedInstance] setActive: YES error: &activationError];



来源:https://stackoverflow.com/questions/32737130/background-audio-not-working-with-xcode-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!