-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
97 lines (85 loc) · 2.53 KB
/
index.html
File metadata and controls
97 lines (85 loc) · 2.53 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>👋</title>
<style>
body,
html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
background-color: #000;
touch-action: none;
}
iframe {
position: absolute;
top: 50%;
left: 50%;
width: 100vw;
height: 100vh;
transform: translate(-50%, -50%);
border: 0;
pointer-events: none;
}
@media (min-aspect-ratio: 16/9) {
iframe {
height: 56.25vw;
}
}
@media (max-aspect-ratio: 16/9) {
iframe {
width: 177.78vh;
}
}
#overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
</style>
</head>
<body>
<div id="player"></div>
<div id="overlay"></div>
<script>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
document.body.appendChild(tag);
var player;
function onYouTubeIframeAPIReady() {
// Handle subdirectories (e.g. github.io/repo/ID) by taking the last segment
const pathSegments = window.location.pathname.split('/').filter(p => p && p !== 'index.html');
let vidId = pathSegments.pop();
if (!vidId) {
vidId = 'dQw4w9WgXcQ';
}
player = new YT.Player('player', {
height: '100%',
width: '100%',
videoId: vidId,
playerVars: { 'autoplay': 1, 'mute': 1, 'controls': 0, 'playsinline': 1, 'loop': 1, 'playlist': vidId, 'rel': 0 },
events: {
'onReady': function (e) {
e.target.setVolume(100);
e.target.playVideo();
}
}
});
}
document.getElementById('overlay').addEventListener('click', function () {
if (player && typeof player.unMute === 'function') {
player.unMute();
player.setVolume(100);
player.playVideo();
}
});
</script>
</body>
</html>