This repository has been archived by the owner on Feb 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (60 loc) · 1.99 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PVP Web</title>
<style>
#app {
display: flex;
flex-direction: column;
align-items: center;
}
</style>
</head>
<body>
<div id="app">
<div id="player"></div>
<div id="control"></div>
<div>Made with ❤️ by
<a href="https://github.com/suisei-cn">suisei-cn</a>,
<a href="https://github.com/suisei-cn/pvp-web">source</a></div>
</div>
<script src="pvp.js"></script>
<script>
// Set the H/W
const fac = 0.5625
const videoHeightPercent = 0.6
const videoWidthPercent = 0.8
const size = {
width: window.innerWidth || document.body.clientWidth,
height: window.innerHeight || document.body.clientHeight
}
const standardWidth = Math.min(size.height * videoHeightPercent * (1 / fac) * (1 / videoWidthPercent), size.width * videoWidthPercent)
const url = new URL(window.location);
const vid = url.searchParams.get("v") || "vQHVGXdcqEQ"
const tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
const firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: String(standardWidth * fac),
width: String(standardWidth),
videoId: vid,
events: {
'onReady': setupPvp
}
});
}
function setupPvp() {
var pvp = new Pvp({
videoId: vid,
player,
container: document.querySelector("#control")
})
}
</script>
</body>
</html>