soylent / weblink

Use your web browser as a proxy server.
31 stars 2 forks source link

Adds NoSleepJs library to prevent iOS and Android devices from sleeping upon user intervention #9

Closed zakir8 closed 2 years ago

zakir8 commented 2 years ago

Problem: Most phones are set to a minute timeout and iOS web server seems to be disconnected if phone screen gets timeout. It's not a pleasant scenario if the phone is not on charge all the time while using this.

Solution: A way to keep browsers active is by playing a audio/video in a loop in the background. This allows the weblink server to always be active to passthrough the traffic. I utilized a library called NoSleep.js to keep the session active and included a button on the webpage for the user to make it active. I am using a CDN minified version of the library for better access. This file once loaded in a browser seems to be cached.

image

Please let me know if you have any questions or concerns.

soylent commented 2 years ago

Great idea and implementation, thank you! I usually disable screen auto-lock in the settings, but this feature makes the user experience much better.

I can't think of a reason to have the disable button since your phone must be unlocked for the app to function correctly. So I think it's better to remove it and keep this feature always on.

zakir8 commented 2 years ago

Great idea and implementation, thank you! I usually disable screen auto-lock in the settings, but this feature makes the user experience much better.

I can't think of a reason to have the disable button since your phone must be unlocked for the app to function correctly. So I think it's better to remove it and keep this feature always on.

I had thought about that, and actually wanted to make that implementation. It's actually not allowed due to browser policies for autoplay upon page load. Here is more information: https://developer.chrome.com/blog/autoplay/

It would need user intervention to allow playing audio/video on the page; hence also needed for NoSleepjs. I believe what can be done here is button removal upon activation. What do you think?

soylent commented 2 years ago

Hi @zakir8 Sorry for the late reply. It makes sense, thanks. I've made a few minor changes to your PR. Hope you don't mind.

zakir8 commented 2 years ago

I just tried your changes out. I like that there is a reset mechanism now when a user comes back to the page.

soylent commented 2 years ago

Released as v1.2.0