Allow “auto lock” while video is being played

前端 未结 2 490
甜味超标
甜味超标 2020-12-09 13:54

No matter whether I am using MPMoviePlayerController or AVPlayer (AVFoundation), the iOS does not allow the device to auto lock

2条回答
  •  悲哀的现实
    2020-12-09 14:38

    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"];
    }
    

提交回复
热议问题