How to allow iPhone auto-lock while playing a video

后端 未结 2 776
没有蜡笔的小新
没有蜡笔的小新 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: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.

提交回复
热议问题