ios - Allow "auto lock" while video is being played -
no matter whether using mpmovieplayercontroller
or avplayer
(avfoundation
), ios not allow device auto lock (to enter sleep mode) while video playing.
i have case extremely slow video being played in loop in background. while video playing, device never goes sleep.
so far, option have detect when user did not make actions while , pause video. after that, device counts down "auto lock" duration specified in ios settings.
i looking alternative avplayer
make possible.
similar questions:
how allow iphone auto-lock while playing video
is possible set avplayer allow device go sleep during video playback?
how enable iphone auto lock during mpmovieplayer playback?
i had idea use html5 video inside uiwebview
, ios not allow autoplay on those.
remember private api, i'm not sure if can use appstore release or not.
tested on ios 9.
avplayer *player = // alloc init... if ([player respondstoselector:nsselectorfromstring(@"_preventssleepduringvideoplayback")]) { [player setvalue:@(no) forkey:@"preventssleepduringvideoplayback"]; }
Comments
Post a Comment