Skip to content

Commit 36fbefa

Browse files
committed
Don’t autoplay video on devices with low battery
This is slightly ineffective as the Battery API returns a Promise _after_ the video has already started auto-playing. But it’s a neat example for example’s sake.
1 parent 95aacfa commit 36fbefa

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

demo/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ <h2><code>&lt;video&gt;</code> Demo</h2>
325325
video.preload = 'metadata';
326326
}
327327

328+
if (window.obs?.batteryLow === true) {
329+
video.autoplay = false;
330+
}
331+
328332
videoWrapper.appendChild(video);
329333

330334
}

0 commit comments

Comments
 (0)