Skip to content

Commit

Permalink
fix: enable wakelock for avplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
imzlh committed Sep 21, 2024
1 parent f18e76c commit 95cb6e8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/opener/avplayer/avplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ export default async function create(el){
player.on('time', time => el.currentTime = time);
player.on('progress', prop => el.dispatchEvent(new CustomEvent('progress', {detail: prop})))

// WebLock
if('wakeLock' in navigator){
let lock;
player.on('played', () =>
navigator.wakeLock.request('screen')
.then(lo => lock = lo)
.catch(() => console.warn('Failed to request wake lock'))
);
player.on('paused', () => lock && lock.release());
}

return refs;
}

Expand Down

0 comments on commit 95cb6e8

Please sign in to comment.