Skip to content

Commit 69d3bad

Browse files
Merge pull request #1550 from Avdhesh-Varshney/videoPlayer
[SSoC 2.0] Video Player Project Ready
2 parents fca466a + 5557d14 commit 69d3bad

8 files changed

Lines changed: 292 additions & 1 deletion

File tree

Projects/Video-Player/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# **VIDEO PLAYER**
2+
3+
---
4+
5+
6+
## **Description 📃**
7+
- This project made by using HTML, CSS and JS
8+
- In this project, Enter the data path of any file with extension on the javascript file in the array `currentDirVideoFiles`
9+
- This will enlist all the video files on the webpage.
10+
- Now, you can enjoy the video player application.
11+
12+
13+
<br>
14+
15+
## **Tech Stack 🎮**
16+
- HTML
17+
- CSS
18+
- JS
19+
20+
21+
<br>
22+
23+
## **Working Video 📸**
24+
25+
https://github.com/TusharKesarwani/Front-End-Projects/assets/114330097/da6ac275-6532-49b6-98ca-5cdc83e41613
26+
27+
28+
<br>
29+
30+
## **Created By 👦**
31+
32+
[Avdhesh Varshney](https://github.com/Avdhesh-Varshney)
33+
34+
35+
<br>
36+
37+
### **Thanks for using this application 🎉**
38+

Projects/Video-Player/index.html

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
8+
<!-- Logo of the website -->
9+
<link rel="shortcut icon" href="./logo.png" type="image/x-icon">
10+
11+
<!-- Title of the website -->
12+
<title>Video Player</title>
13+
14+
<!-- stylesheet of website -->
15+
<link rel="stylesheet" href="./style.css">
16+
</head>
17+
18+
<body>
19+
<!-- Main container of the video player -->
20+
<div class="container">
21+
<!-- Heading of the video player -->
22+
<h1>VIDEO PLAYER</h1>
23+
24+
<!-- Created by -->
25+
<h3>Created By <a href="https://github.com/Avdhesh-Varshney">Avdhesh Varshney</a></h3>
26+
27+
<!-- Video container to enlist all the videos -->
28+
<div class="video-container"></div>
29+
30+
<!-- On click video is played there -->
31+
<div class="popup-video">
32+
<!-- Cross button -->
33+
<span>&times;</span>
34+
35+
<!-- Video playing -->
36+
<video src="#" muted autoplay controls></video>
37+
</div>
38+
39+
</div>
40+
41+
<!-- Main javascript file -->
42+
<script src="./script.js"></script>
43+
</body>
44+
45+
</html>

Projects/Video-Player/logo.png

31.8 KB
Loading

Projects/Video-Player/script.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Array of video file names in the current directory
2+
var currentDirVideoFiles = [
3+
'video.mp4',
4+
'video.mp4',
5+
'video.mp4',
6+
'video.mp4',
7+
'video.mp4',
8+
'video.mp4'
9+
];
10+
11+
// Get the video container element from the HTML document
12+
const videoContainer = document.getElementsByClassName('video-container')[0];
13+
14+
// Function to create video elements based on the provided array of video files
15+
function createElements(arr) {
16+
17+
for (let i = 0; i < arr.length; i++) {
18+
// Create a div element for each video
19+
let videoDiv = document.createElement('div');
20+
videoDiv.classList = 'video';
21+
22+
// Create a video element
23+
let video = document.createElement('video');
24+
video.muted = true;
25+
26+
// Path of the video
27+
video.src = `./${arr[i]}`;
28+
29+
// Adding the feature so that user does not download the video
30+
video.controlsList.add('nodownload');
31+
32+
// Adding the option so that menu option will remove/disable
33+
video.oncontextmenu = function (e) {
34+
e.preventDefault();
35+
};
36+
37+
// Append the video element to the video div
38+
videoDiv.appendChild(video);
39+
40+
// Append the video div to the video container
41+
videoContainer.appendChild(videoDiv);
42+
}
43+
}
44+
45+
// Function to handle the click events of video elements
46+
function load() {
47+
48+
// Add click event listener to each video element inside the video container
49+
document.querySelectorAll('.video-container video').forEach(vid => {
50+
vid.onclick = () => {
51+
// Display the popup video container
52+
document.querySelector('.popup-video').style.display = 'block';
53+
54+
// Set the source of the popup video to the clicked video source
55+
document.querySelector('.popup-video video').src = vid.getAttribute('src');
56+
}
57+
});
58+
59+
// Add click event listener to the close button of the popup video
60+
document.querySelector('.popup-video span').onclick = () => {
61+
let videoContainer = document.querySelector('.popup-video');
62+
let video = videoContainer.querySelector('video');
63+
64+
// Pause the video and hide the popup video container
65+
video.pause();
66+
videoContainer.style.display = 'none';
67+
}
68+
}
69+
70+
// Initialization function
71+
function init() {
72+
// Create video elements based on the current directory video files
73+
createElements(currentDirVideoFiles);
74+
75+
// Wait for some time before attaching the event listeners
76+
setTimeout(load, 1500);
77+
}
78+
79+
// Call the init function to start the process
80+
init();
81+
82+
// Adding the option so that menu option will remove/disable
83+
document.addEventListener('contextmenu', function (e) {
84+
e.preventDefault();
85+
});

Projects/Video-Player/style.css

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
* {
2+
margin: 0;
3+
padding: 0;
4+
box-sizing: border-box;
5+
text-transform: capitalize;
6+
font-family: Verdana, Geneva, Tahoma, sans-serif;
7+
user-select: none;
8+
}
9+
10+
.container {
11+
position: relative;
12+
min-height: 100vh;
13+
background-color: #334;
14+
}
15+
16+
.container h1 {
17+
color: #fff;
18+
text-align: center;
19+
padding: 15px;
20+
font-size: 40px;
21+
font-weight: normal;
22+
}
23+
24+
.container h3 {
25+
color: #fff;
26+
text-align: center;
27+
margin-bottom: 30px;
28+
margin-top: 10px;
29+
font-weight: normal;
30+
}
31+
32+
.container h3 a {
33+
color: #fff;
34+
text-decoration: none;
35+
}
36+
37+
.container h3 a:hover {
38+
text-decoration: underline;
39+
}
40+
41+
.container .video-container {
42+
display: flex;
43+
flex-wrap: wrap;
44+
gap: 35px;
45+
justify-content: center;
46+
padding: 10px;
47+
}
48+
49+
.container .video-container .video {
50+
height: 350px;
51+
width: 350px;
52+
border: 5px solid #fff;
53+
border-radius: 5px;
54+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.7);
55+
cursor: pointer;
56+
overflow: hidden;
57+
}
58+
59+
.container .video-container .video video {
60+
padding: 10px;
61+
height: 100%;
62+
width: 100%;
63+
object-fit: cover;
64+
transition: 0.2s linear;
65+
}
66+
67+
.container .video-container .video:hover video {
68+
transform: scale(1.1);
69+
}
70+
71+
.container .popup-video {
72+
position: fixed;
73+
top: 0;
74+
left: 0;
75+
z-index: 100;
76+
background: rgba(0, 0, 0, 0.8);
77+
height: 100%;
78+
width: 100%;
79+
display: none;
80+
}
81+
82+
.container .popup-video video {
83+
position: absolute;
84+
top: 50%;
85+
left: 50%;
86+
transform: translate(-50%, -50%);
87+
width: 750px;
88+
border-radius: 5px;
89+
border: 3px solid #fff;
90+
object-fit: cover;
91+
}
92+
93+
.container .popup-video span {
94+
position: absolute;
95+
top: 5px;
96+
right: 20px;
97+
font-size: 50px;
98+
color: #fff;
99+
font-weight: bolder;
100+
z-index: 100;
101+
cursor: pointer;
102+
}
103+
104+
@media (max-width: 768px) {
105+
.container .popup-video video {
106+
width: 95%;
107+
}
108+
}

Projects/Video-Player/video.mp4

761 KB
Binary file not shown.

img/projects/Video_Player.png

252 KB
Loading

projects.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,14 +1031,29 @@ const projects = [
10311031
"github-link":"https://github.com/TusharKesarwani/Front-End-Projects/tree/main/Projects/Playable_Piano",
10321032
"project-link":"Projects/Playable_Piano/index.html"
10331033
},
1034-
1034+
{
1035+
"title":"Solar System Model",
1036+
"tags":["HTML","CSS","JavaScript"],
1037+
"img":"img/projects/Solar_System_Model.png",
1038+
"description":"Solar system model is the animated project using CSS. It is built using HTML, CSS and JavaScript. It is a responsive website that can be viewed on any device. Adding data of different solar bodies will makes this website more informative.",
1039+
"github-link":"https://github.com/TusharKesarwani/Front-End-Projects/tree/main/Projects/Solar%20System%20Model",
1040+
"project-link":"Projects/Solar%20System%20Model/index.html"
1041+
},
10351042
{
10361043
"title":"Sound Equalizer",
10371044
"tags":["HTML","CSS","JavaScript"],
10381045
"img":"img/projects/Sound_Equalizer.png",
10391046
"description":"Sound Equalizer is a clone of the sound equalizer system. It is built using HTML, CSS and JavaScript. It is a responsive website that can be viewed on any device.",
10401047
"github-link":"https://github.com/TusharKesarwani/Front-End-Projects/tree/main/Projects/Sound_Equalizer",
10411048
"project-link":"Projects/Sound_Equalizer/index.html"
1049+
},
1050+
{
1051+
"title":"Video Player",
1052+
"tags":["HTML","CSS","JavaScript"],
1053+
"img":"img/projects/Video_Player.png",
1054+
"description":"This website can be used to play videos. This application give the feeling of video gallery as of our mobile phone.",
1055+
"github-link":"https://github.com/TusharKesarwani/Front-End-Projects/tree/main/Projects/Video-Player",
1056+
"project-link":"Projects/Video-Player/index.html"
10421057
}
10431058
]
10441059

0 commit comments

Comments
 (0)