zakj / no-sleep Goto Github PK
View Code? Open in Web Editor NEWThis project forked from richtr/nosleep.js
Prevent display sleep and enable wake lock in any Android or iOS web browser.
License: MIT License
This project forked from richtr/nosleep.js
Prevent display sleep and enable wake lock in any Android or iOS web browser.
License: MIT License
It will be great to have "Title" as param.
I like to pass the title like "App name" to the video Title.
The reason is that "No Sleep" is not much informative for end user of app and have to be somehow explained in the app.
So (maybe) when no sleep video will have "App Name - No sleep" in the name, the user will know what going on.
Thank you.
Can you please add panel? I think it would be a big improvement. Thanks.
I wonder if it should work on chrome
/ safari
on with linux
/ windows
/ macos
?
And why user interaction is required if we can use hidden video
I was experiencing intermittent failures of the sleep prevention in my app. I discovered that sometimes the video used by no-sleep on iOS standalone (home screen app) would reach the end and stop playing without a timeupdate
event firing. This seems most prone to occurring when the app is busy (blocking the thread) for a sustained period of time. I created a fork of noslee.page at https://sgilroy.github.io/nosleep.page to demonstrate the problem (and a mitigation).
The currentTime
was being set to Math.random()
, which can occasionally results in a time at or near 1.0 second, leaving very little time before the end of the video is reached. The video is only 1.048 seconds in duration. There are actually two video files (webm and mp4), but they are very close in length.
To mitigate the problem I made two changes:
currentTime
in the event handler for timeupdate
, Math.random() * 0.5
instead of Math.random()
.playbackRate
to 0.1, effectively stretching out the video from 1.048 seconds to approximately 10 seconds.These changes are available in my fork https://github.com/sgilroy/no-sleep and published in the NPM package https://www.npmjs.com/package/@scottjgilroy/no-sleep.
Note that I did try using loop
on the video instead of the timeupdate
event, but on iOS this does not seem to be effective in preventing sleep. I did not investigate setting currentTime
to 0 instead of a random value, based on the assumption that this strange approach had been introduced for some good reason (such as performance or .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.