Prevent iOS mobile safari from going idle / auto-locking / sleeping?

后端 未结 6 776
星月不相逢
星月不相逢 2020-12-04 10:32

In an iOS app you can set application.idleTimerDisabled = YES to prevent the phone from auto locking.

I need to do this in mobile safari for a game li

6条回答
  •  隐瞒了意图╮
    2020-12-04 11:31

    NoSleep.js seems to work in iOS 11 and it reportedly works on Android as well.


    Old answer

    This is a simple HTML-only method to do that: looping inline autoplaying videos (it might also work in Android Chrome 53+)

    See the same demo on CodePen (includes a stopwatch)

    Notes

    • Avoid loading a big video just for this. Perhaps make a short, tiny, black-only video or use
    • To make it fully work, the videos needs to be always in the viewport or you need to start its playback via JS: video.play()

提交回复
热议问题