w1100n
This site is best viewed in Google Chrome
6/2/2019 22:19

chrome://flags/#enable-experimental-web-platform-features

Note: Like most other powerful web APIs, the Wake Lock API is only available when served over HTTPS.

let wakeLock;
let wakeLockRequest;

async function toggleWakeLock() {
  if ('getWakeLock' in navigator) {
    console.log('', 'navigator.getWakeLock is supported');
    try {
      wakeLock = await navigator.getWakeLock("screen");
      updateStatus(wakeLock);
      // Listen for changes to the wakeLock
      wakeLock.addEventListener('activechange', (e) => {
        updateStatus(wakeLock);
      });
      wakeLockRequest = wakeLock.createRequest();
    } catch (ex) {

      console.error(ex);
    }
  } else {
    console.warn('navigator.getWakeLock is not supported');

  }

}

function updateStatus(wakeLock) {
  console.log(wakeLock);
}

https://developers.google.com/web/updates/2018/12/wakelock
https://chromestatus.com/features/4636879949398016
https://wake-lock.glitch.me/screen.html

https://medium.com/dev-channel/experimenting-with-the-wake-lock-api-b6f42e0a089f
https://bugs.chromium.org/p/chromium/issues/detail?id=257511

<< Previous Posts Newer Posts >>
辽ICP备14012896