Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/khushi89012/js_awaker
https://github.com/khushi89012/js_awaker
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/khushi89012/js_awaker
- Owner: khushi89012
- Created: 2024-04-24T06:43:43.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-04-24T06:44:06.000Z (7 months ago)
- Last Synced: 2024-04-24T13:26:33.595Z (7 months ago)
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Js_awaker
# Screen Wake Lock Example
This repository demonstrates how to utilize the Screen Wake Lock API to prevent a device's screen from dimming or locking during a video call.
## Overview
The Screen Wake Lock API provides a way to prevent devices from dimming or locking the screen automatically, ensuring that important activities such as video calls remain uninterrupted.
## Getting Started
To use the Screen Wake Lock API, follow these steps:
1. Include the code provided in your project.
2. Call the `startVideoCall()` function when initiating a video call.
3. The `requestWakeLock()` function requests a wake lock to prevent the screen from dimming or locking during the video call.
4. The `releseWakeLock()` function releases the wake lock after a specified duration (default: 10 minutes).
## Code Example
```javascript
async function requestWakeLock(){
try{
wakeLock = await navigator.wakeLock.request('screen')
console.log("Screen wake lock is activated")
}
catch(err){
console.error("Error requesting : ",err.message)
}
}const releseWakeLock = ()=> wakeLock && wakeLock.release()
const startVideoCall = ()=>{
requestWakeLock()
setTimeout(releseWakeLock,600000)
}