no-sleep-app
Version:
NoSleepApp is a lightweight JavaScript library that prevents devices from going to sleep during critical activities. It uses the Screen Wake Lock API or a fallback video playback method to keep the screen active, ensuring uninterrupted user experiences ac
1,150 lines (213 loc) • 11.1 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Global</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2></h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="isEnabled"><span class="type-signature"></span>isEnabled<span class="type-signature"></span></h4>
<div class="description">
Checks if NoSleepApp is enabled.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line60">line 60</a>
</li></ul></dd>
</dl>
<h4 class="name" id="isOldIOS"><span class="type-signature">(constant) </span>isOldIOS<span class="type-signature"></span></h4>
<div class="description">
Determines if the current device is running an older version of iOS (pre-iOS 10).
This is useful for applying platform-specific workarounds for older iOS devices.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="detect.js.html">detect.js</a>, <a href="detect.js.html#line7">line 7</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="disable"><span class="type-signature"></span>disable<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Disables NoSleepApp functionality.
Stops Wake Lock, iOS hack, or video playback depending on the platform.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line135">line 135</a>
</li></ul></dd>
</dl>
<h4 class="name" id="enable"><span class="type-signature">(async) </span>enable<span class="signature">()</span><span class="type-signature"> → {Promise.<void>}</span></h4>
<div class="description">
Enables the NoSleepApp functionality.
Uses the Wake Lock API, older iOS hack, or video playback as appropriate.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line70">line 70</a>
</li></ul></dd>
</dl>
<h5>Throws:</h5>
<dl>
<dt>
<div class="param-desc">
Throws an error if enabling fails.
</div>
</dt>
<dd></dd>
<dt>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Error</span>
</dd>
</dl>
</dt>
<dd></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolves when enabling is complete.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<void></span>
</dd>
</dl>
<h4 class="name" id="handleFullscreenChange"><span class="type-signature"></span>handleFullscreenChange<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Handles the `fullscreenchange` event.
Invokes the callback if the document enters fullscreen mode.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visibility-listener.js.html">visibility-listener.js</a>, <a href="visibility-listener.js.html#line50">line 50</a>
</li></ul></dd>
</dl>
<h4 class="name" id="handleVisibilityChange"><span class="type-signature"></span>handleVisibilityChange<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Handles the `visibilitychange` event.
Invokes the callback if the document is visible.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visibility-listener.js.html">visibility-listener.js</a>, <a href="visibility-listener.js.html#line40">line 40</a>
</li></ul></dd>
</dl>
<h4 class="name" id="isNativeWakeLockSupported"><span class="type-signature"></span>isNativeWakeLockSupported<span class="signature">()</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Determines if the native Wake Lock API is supported.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line14">line 14</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
True if Wake Lock API is supported.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="pause"><span class="type-signature"></span>pause<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Pauses the video, stopping its effect of preventing sleep.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="no-sleep-element.js.html">no-sleep-element.js</a>, <a href="no-sleep-element.js.html#line80">line 80</a>
</li></ul></dd>
</dl>
<h4 class="name" id="play"><span class="type-signature"></span>play<span class="signature">()</span><span class="type-signature"> → {Promise.<void>}</span></h4>
<div class="description">
Plays the video to keep the device awake.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="no-sleep-element.js.html">no-sleep-element.js</a>, <a href="no-sleep-element.js.html#line73">line 73</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Resolves when playback successfully starts.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<void></span>
</dd>
</dl>
<h4 class="name" id="removeListeners"><span class="type-signature"></span>removeListeners<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Removes the event listeners for visibility and fullscreen changes.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visibility-listener.js.html">visibility-listener.js</a>, <a href="visibility-listener.js.html#line59">line 59</a>
</li></ul></dd>
</dl>
<h4 class="name" id="setMetadataListener"><span class="type-signature"></span>setMetadataListener<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Sets up a listener for the `loadedmetadata` event on the video element.
This ensures the video behaves correctly based on its duration.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="no-sleep-element.js.html">no-sleep-element.js</a>, <a href="no-sleep-element.js.html#line41">line 41</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="module.exports.html">exports</a></li></ul><h3>Global</h3><ul><li><a href="global.html#disable">disable</a></li><li><a href="global.html#enable">enable</a></li><li><a href="global.html#handleFullscreenChange">handleFullscreenChange</a></li><li><a href="global.html#handleVisibilityChange">handleVisibilityChange</a></li><li><a href="global.html#isEnabled">isEnabled</a></li><li><a href="global.html#isNativeWakeLockSupported">isNativeWakeLockSupported</a></li><li><a href="global.html#isOldIOS">isOldIOS</a></li><li><a href="global.html#pause">pause</a></li><li><a href="global.html#play">play</a></li><li><a href="global.html#removeListeners">removeListeners</a></li><li><a href="global.html#setMetadataListener">setMetadataListener</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Fri Nov 22 2024 23:19:12 GMT+0000 (Greenwich Mean Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>