-
Notifications
You must be signed in to change notification settings - Fork 0
/
pk2.html
84 lines (79 loc) · 2.25 KB
/
pk2.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Hero Section</title>
<style>
.hero {
position: relative;
width: 100%;
height: 80vh;
overflow: hidden;
}
#player {
position: absolute;
top: 50%;
left: 50%;
width: 100vw;
height: 56.25vw; /* 16:9 aspect ratio */
transform: translate(-50%, -50%);
min-width: 177.77vh; /* 16:9 aspect ratio */
min-height: 100vh;
}
.controls {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
z-index: 10;
}
.controls button {
margin: 0 5px;
padding: 10px 20px;
font-size: 16px;
}
</style>
</head>
<body>
<div class="hero">
<div id="player"></div>
<div class="controls">
<button id="prevBtn">Previous</button>
<button id="nextBtn">Next</button>
</div>
</div>
<script src="https://www.youtube.com/iframe_api"></script>
<script>
let player;
const playlistId = 'PLQ2eZ195XtL1AaIvU8iqpyVZiRkYK1vRT';
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '100%',
width: '100%',
playerVars: {
listType: 'playlist',
list: playlistId,
autoplay: 1,
controls: 0,
showinfo: 0,
rel: 0
},
events: {
'onReady': onPlayerReady
}
});
}
function onPlayerReady(event) {
event.target.mute(); // Mute to allow autoplay
event.target.playVideo();
}
document.getElementById('prevBtn').addEventListener('click', () => {
player.previousVideo();
});
document.getElementById('nextBtn').addEventListener('click', () => {
player.nextVideo();
});
</script>
</body>
</html>