No matter whether I am using MPMoviePlayerController or AVPlayer (AVFoundation), the iOS does not allow the device to auto lock
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#