Open skibulk opened 4 years ago
I solve the problem like this
document.addEventListener('visibilitychange', function () { handleVisibilityChange(noSleep) })
function handleVisibilityChange (noSleep) {
if (document.hidden) {
noSleep.disable()
} else {
document.addEventListener('click', function enableNoSleep () {
document.removeEventListener('click', enableNoSleep)
noSleep.enable()
})
}
}
I have same problem on ipad 14.6 but is ok on version 14.4,
I used window.addEventListener("blur", function(event){
noSleep = new NoSleep();
noSleep.enable();
});
to create new instance and enable it , it still does not work on ipad Pro v14.6
who have any suggstion .
Hello. Using your demo page, if I hit the power button on my phone to turn it off, then turn it back on, screen lock is re-enabled. I expected that since a user event is required to enable NoSleep, however, if I then manually disable and re-enable NoSleep, the screen still turns off after a minute or so. I'm using Safari on an iPhone 6, IOS 12.4.3.
I'm currently solving this by re-instantiating NoSleep and requiring the user to click in the app to re-enable it. Is the first instance of NoSleep / the first video kept in memory though?
Proposed solution: On blur, within the NoSleep instance itself, automatically disable NoSleep, remove the old video element, and create a new video element.