-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
56 lines (54 loc) · 1.82 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTube Player with Custom Thumbnail</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f4f4f4;
}
.video-container {
position: relative;
width: 560px;
height: 315px;
}
.video-container img {
width: 100%;
height: 100%;
cursor: pointer;
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: none;
}
</style>
</head>
<body>
<div class="video-container">
<!-- Replace 'YOUR_THUMBNAIL_URL' with the custom thumbnail URL -->
<img src="https://static.wikia.nocookie.net/antagonisten/images/a/aa/Subway_Surfers.jpg/revision/latest/scale-to-width-down/1200?cb=20220517145711&path-prefix=de" alt="Custom Thumbnail" id="thumbnail">
<!-- Replace 'VIDEO_ID' with the actual YouTube video ID -->
<iframe id="youtubePlayer" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<script>
const thumbnail = document.getElementById('thumbnail');
const youtubePlayer = document.getElementById('youtubePlayer');
thumbnail.addEventListener('click', () => {
thumbnail.style.display = 'none';
youtubePlayer.style.display = 'block';
});
</script>
</body>
</html>