How to support airplay in the background in iOS6

安稳与你 提交于 2019-12-07 06:43:22

问题


My app should stream video's to an AppleTV via Airplay, even when the app is in the background.

Under iOS5 it worked perfectly. In iOS6 it does not.

Xcode gives me a deprecated warning on this line of code:

moviePlayerViewController.moviePlayer.useApplicationAudioSession = NO;

Is this the reason why my app isn't functioning correctly anymore. What is the equivalent of this piece of code in iOS6?


回答1:


Found the solution: this problem can be solved by setting the right AVAudioSessionCategory

NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error: &setCategoryError];



回答2:


Besides @murze's solution you should also set value App plays audio for Required background modes key in infoPlist file like @ACBurk suggested: https://stackoverflow.com/a/8807958/384864



来源:https://stackoverflow.com/questions/12814574/how-to-support-airplay-in-the-background-in-ios6

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