Skip to content

Commit 7cf6d2b

Browse files
Merge pull request #728 from Harshini-Purushothaman/main
youtube clone
2 parents 48fea27 + 7e1a8c6 commit 7cf6d2b

File tree

5 files changed

+108
-0
lines changed

5 files changed

+108
-0
lines changed

youtube-clone/index.html

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>YouTube Clone</title>
7+
<link rel="stylesheet" href="styles.css">
8+
</head>
9+
<body>
10+
<header>
11+
<h1>YouTube Clone</h1>
12+
<input type="text" id="search" placeholder="Search...">
13+
</header>
14+
<main>
15+
<div id="video-container"></div>
16+
<div id="video-player" style="display: none;">
17+
<video controls id="video-element">
18+
<source id="video-source" src="" type="video/mp4">
19+
Your browser does not support the video tag.
20+
</video>
21+
<button onclick="closePlayer()">Close</button>
22+
</div>
23+
</main>
24+
<script src="script.js"></script>
25+
</body>
26+
</html>

youtube-clone/script.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const videos = [
2+
{
3+
title: 'How to Install Visual Studio Code on Windows 11 (VS Code) (2024)',
4+
src: 'videos/How Install Visual Studio Code on Windows 11 (VS Code) (2024).mp4',
5+
thumbnail: 'thumbnails/vscode.jpeg',
6+
},
7+
// You can add more videos here if needed
8+
];
9+
10+
const videoContainer = document.getElementById('video-container');
11+
12+
function loadVideos() {
13+
videos.forEach(video => {
14+
const videoElement = document.createElement('div');
15+
videoElement.className = 'video';
16+
videoElement.innerHTML = `
17+
<img src="${video.thumbnail}" alt="${video.title}" onclick="playVideo('${video.src}')">
18+
<h3>${video.title}</h3>
19+
`;
20+
videoContainer.appendChild(videoElement);
21+
});
22+
}
23+
24+
function playVideo(src) {
25+
document.getElementById('video-source').src = src;
26+
document.getElementById('video-element').load();
27+
document.getElementById('video-player').style.display = 'block';
28+
}
29+
30+
function closePlayer() {
31+
document.getElementById('video-player').style.display = 'none';
32+
}
33+
34+
document.getElementById('search').addEventListener('input', function() {
35+
const query = this.value.toLowerCase();
36+
const filteredVideos = videos.filter(video => video.title.toLowerCase().includes(query));
37+
videoContainer.innerHTML = '';
38+
filteredVideos.forEach(video => {
39+
const videoElement = document.createElement('div');
40+
videoElement.className = 'video';
41+
videoElement.innerHTML = `
42+
<img src="${video.thumbnail}" alt="${video.title}" onclick="playVideo('${video.src}')">
43+
<h3>${video.title}</h3>
44+
`;
45+
videoContainer.appendChild(videoElement);
46+
});
47+
});
48+
49+
window.onload = loadVideos;

youtube-clone/styles.css

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
body {
2+
font-family: Arial, sans-serif;
3+
margin: 0;
4+
padding: 0;
5+
}
6+
header {
7+
background-color: #f8f8f8;
8+
padding: 10px;
9+
text-align: center;
10+
}
11+
#video-container {
12+
display: flex;
13+
flex-wrap: wrap;
14+
justify-content: center;
15+
padding: 10px;
16+
}
17+
.video {
18+
margin: 10px;
19+
width: 300px;
20+
}
21+
.video img {
22+
width: 100%;
23+
cursor: pointer;
24+
}
25+
#video-player {
26+
position: fixed;
27+
top: 50%;
28+
left: 50%;
29+
transform: translate(-50%, -50%);
30+
background: white;
31+
padding: 20px;
32+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
33+
}

youtube-clone/thumbnails/vscode.jpeg

10.4 KB
Loading

0 commit comments

Comments
 (0)