Allow “auto lock” while video is being played

微笑、不失礼 提交于 2019-11-28 09:32:19

Remember this is private API, I'm not sure if you can use it for appstore release or not.

Tested on iOS 9.

AVPlayer *player = // alloc init...
if ([player respondsToSelector:NSSelectorFromString(@"_preventsSleepDuringVideoPlayback")]) {
    [player setValue:@(NO) forKey:@"preventsSleepDuringVideoPlayback"];
}

With iOS 12 this is now possible by setting

let player = AVPlayer()
player.preventsDisplaySleepDuringVideoPlayback = false

See: https://developer.apple.com/documentation/avfoundation/avplayer/2990522-preventsdisplaysleepduringvideop#

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