Home  >  Q&A  >  body text

screen - HTML5 canvas 怎样防止屏幕自动睡眠并检测(手机和平板)锁屏事件?

在GitHub看到这个项目,但那个是针对video标签的,而且issues里面一堆反馈XX设备测试无效的。。。

然后是检测手动锁屏,这个用Page Visitable API能在Android实现,但我在iOS7测试失败(包括chrome),不知是不是iOS版本过低的原因。。。
而且对于桌面来说,如果直接切换窗口(整个浏览器为非活动窗口),这个API也没反应。。。

天蓬老师天蓬老师2717 days ago445

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 14:01:35

    Looping a one-second (very short) video in Android can prevent automatic sleep. Finally, there is no need to use new APIs that are not officially supported by browsers. iOS seems to use a JavaScript timer to continuously self.location to prevent the screen from automatically sleeping, but it is said that this is not effective in iOS7. . .

    Using Page Visitable API on Android can detect lock screen events, but the test on iOS7 is invalid. It is not clear on other versions of iOS.

    Not completely resolved, continue to wait for the answer.

    reply
    0
  • Cancelreply