Skip to content

Commit

Permalink
Merge pull request #728 from Harshini-Purushothaman/main
Browse files Browse the repository at this point in the history
youtube clone
  • Loading branch information
Ayushparikh-code authored Oct 29, 2024
2 parents 48fea27 + 7e1a8c6 commit 7cf6d2b
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
26 changes: 26 additions & 0 deletions youtube-clone/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YouTube Clone</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>YouTube Clone</h1>
<input type="text" id="search" placeholder="Search...">
</header>
<main>
<div id="video-container"></div>
<div id="video-player" style="display: none;">
<video controls id="video-element">
<source id="video-source" src="" type="video/mp4">
Your browser does not support the video tag.
</video>
<button onclick="closePlayer()">Close</button>
</div>
</main>
<script src="script.js"></script>
</body>
</html>
49 changes: 49 additions & 0 deletions youtube-clone/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const videos = [
{
title: 'How to Install Visual Studio Code on Windows 11 (VS Code) (2024)',
src: 'videos/How Install Visual Studio Code on Windows 11 (VS Code) (2024).mp4',
thumbnail: 'thumbnails/vscode.jpeg',
},
// You can add more videos here if needed
];

const videoContainer = document.getElementById('video-container');

function loadVideos() {
videos.forEach(video => {
const videoElement = document.createElement('div');
videoElement.className = 'video';
videoElement.innerHTML = `
<img src="${video.thumbnail}" alt="${video.title}" onclick="playVideo('${video.src}')">
<h3>${video.title}</h3>
`;
videoContainer.appendChild(videoElement);
});
}

function playVideo(src) {
document.getElementById('video-source').src = src;
document.getElementById('video-element').load();
document.getElementById('video-player').style.display = 'block';
}

function closePlayer() {
document.getElementById('video-player').style.display = 'none';
}

document.getElementById('search').addEventListener('input', function() {
const query = this.value.toLowerCase();
const filteredVideos = videos.filter(video => video.title.toLowerCase().includes(query));
videoContainer.innerHTML = '';
filteredVideos.forEach(video => {
const videoElement = document.createElement('div');
videoElement.className = 'video';
videoElement.innerHTML = `
<img src="${video.thumbnail}" alt="${video.title}" onclick="playVideo('${video.src}')">
<h3>${video.title}</h3>
`;
videoContainer.appendChild(videoElement);
});
});

window.onload = loadVideos;
33 changes: 33 additions & 0 deletions youtube-clone/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #f8f8f8;
padding: 10px;
text-align: center;
}
#video-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 10px;
}
.video {
margin: 10px;
width: 300px;
}
.video img {
width: 100%;
cursor: pointer;
}
#video-player {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: white;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
Binary file added youtube-clone/thumbnails/vscode.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

0 comments on commit 7cf6d2b

Please sign in to comment.