-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathENG_index.html
More file actions
50 lines (45 loc) · 1.14 KB
/
ENG_index.html
File metadata and controls
50 lines (45 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Fullscreen Autoplay Video</title>
<style>
html, body {
margin: 0;
padding: 0;
background: black;
height: 100%;
}
video {
width: 100%;
height: 100%;
object-fit: cover;
}
</style>
</head>
<body>
<video id="video" autoplay muted playsinline loop>
<source src="video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<script>
const video = document.getElementById("video");
function startPlayback() {
video.play().catch(console.warn);
if (document.fullscreenElement === null) {
video.requestFullscreen().catch(console.warn);
}
}
// Start video and fullscreen on page load
window.addEventListener("load", startPlayback);
// Resume playback when tab becomes visible again
document.addEventListener("visibilitychange", () => {
if (!document.hidden) {
startPlayback();
}
});
// Clicking the video also triggers playback/fullscreen
video.addEventListener("click", startPlayback);
</script>
</body>
</html>