5

I am working on an application that involves using AVPlayer to have a video in the background of an interface.

We've found that while video is playing, the app will never go to sleep. Is there a way to tell AVPlayer to allow the app to go to sleep regardless?

0x6A75616E
  • 4,696
  • 2
  • 33
  • 57
  • Haven't been able to do it myself and I still don't know if there is a way to do it. Just as a comment... After you pause the `AVPlayer`, the auto-lock duration starts counting down. When it expires, the device goes to sleep mode. – AndroC Jun 10 '15 at 12:45
  • This seems like the same question as: http://stackoverflow.com/questions/10267776/how-to-allow-iphone-auto-lock-while-playing-a-video – AndroC Jun 10 '15 at 12:46
  • http://stackoverflow.com/questions/30760826/allow-auto-lock-while-video-is-being-played – AndroC Jun 10 '15 at 15:43
  • See my answer here http://stackoverflow.com/a/38018555/1017340 – Mojtaba Jun 24 '16 at 16:58

1 Answers1

1

Set preventsDisplaySleepDuringVideo to false or NO on the AVPlayer instance.

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

Fabian
  • 6,973
  • 2
  • 26
  • 27