-
Notifications
You must be signed in to change notification settings - Fork 0
/
pk3.html
91 lines (85 loc) · 2.63 KB
/
pk3.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
85
86
87
88
89
90
91
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' https://www.youtube.com https://s.ytimg.com; frame-src https://www.youtube.com;">
<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,
'onError': onPlayerError
}
});
}
function onPlayerReady(event) {
event.target.mute(); // Mute to allow autoplay
event.target.playVideo();
}
function onPlayerError(event) {
console.error('YouTube Player Error:', event.data);
// You can add custom error handling here
}
document.getElementById('prevBtn').addEventListener('click', () => {
player.previousVideo();
});
document.getElementById('nextBtn').addEventListener('click', () => {
player.nextVideo();
});
</script>
</body>
</html>