How to allow iPhone auto-lock while playing a video

后端 未结 2 757
没有蜡笔的小新
没有蜡笔的小新 2021-01-14 20:39

How can I allow iOS device to dim screen and auto-lock the device while playing a video with AVFoundation. Playing a video with AVPlayer disable screen auto-lock by default.

相关标签:
2条回答
  • 2021-01-14 21:09

    I worked on the application where we used AVPlayer to display video backgrounds in application. Our solution was to stop video after some idle time. I mean implementing idle timer on our side. And then send message to all background players to stop them. It's the only good workaround I know.

    0 讨论(0)
  • 2021-01-14 21:20

    why you want screen to go idle while playing video? The real answer is it can't be done. Following are just work arounds with serious downsides.

    The only method apple allows us to use is

    [UIApplication sharedApplication].idleTimerDisabled
    

    You can dim screen programmatically by using a UIView with color black and slowly changing it alpha property to create the illusion of screen going idle.

    0 讨论(0)
提交回复
热议问题