Is there a way to keep Airplay running if the device auto-sleeps/auto-locks?

橙三吉。 提交于 2019-12-19 03:12:21

问题


When streaming a video from an iPhone (or any iOS device) to a TV via Airplay, the stream stops as soon as the device goes to sleep from inactivity. At the moment, I disabled the sleep timer so that the device does not automatically sleep, but is there a better solution to this?

Is setting AVPlayer.externalPlaybackActive enough to allow the OS to know to keep playing when the screen is off? If not, is there an alternate way to keep Airplay running even if the device turns off its screen?


回答1:


To continue airplay playback, add "App plays audio" to the "Required background modes" in the AppName-info.plist

and set the audio session like:

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


来源:https://stackoverflow.com/questions/13206952/is-there-a-way-to-keep-airplay-running-if-the-device-auto-sleeps-auto-locks

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