如何在播放视频时允许 iPhone 自动锁定 [英] How to allow iPhone auto-lock while playing a video

查看:34
本文介绍了如何在播放视频时允许 iPhone 自动锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让 iOS 设备在使用 AVFoundation 播放视频时调暗屏幕并自动锁定设备.使用 AVPlayer 播放视频默认禁用屏幕自动锁定.有没有办法在不暂停视频播放的情况下重新启用它.

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. Is there anyway to re-enable it without pausing the video play.

推荐答案

为什么你想让屏幕在播放视频时空闲?真正的答案是做不到.以下只是具有严重缺点的解决方法.

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

您可以通过使用黑色的 UIView 并缓慢更改其 alpha 属性来以编程方式调暗屏幕,以创建屏幕处于空闲状态的错觉.

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.

这篇关于如何在播放视频时允许 iPhone 自动锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆