ChandimaPrabath
commited on
Commit
•
831e55c
1
Parent(s):
ded211a
0.0.1 Alpha Player
Browse files
frontend/src/components/MoviePlayer.css
CHANGED
@@ -129,11 +129,49 @@
|
|
129 |
cursor: pointer;
|
130 |
}
|
131 |
|
|
|
|
|
|
|
|
|
132 |
.buffering-indicator{
|
133 |
color: white;
|
|
|
134 |
position: fixed;
|
135 |
-
top:
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
cursor: pointer;
|
130 |
}
|
131 |
|
132 |
+
.download-btn{
|
133 |
+
color: white;
|
134 |
+
}
|
135 |
+
|
136 |
.buffering-indicator{
|
137 |
color: white;
|
138 |
+
background-color: #00000069;
|
139 |
position: fixed;
|
140 |
+
top: 0;
|
141 |
+
width: 100dvw;
|
142 |
+
height: 100dvh;
|
143 |
+
display: flex;
|
144 |
+
justify-content: center;
|
145 |
+
align-items: center;
|
146 |
+
}
|
147 |
+
|
148 |
+
.buffering-indicator .position-fix{
|
149 |
+
transform: translate(-50%, -50%);
|
150 |
+
}
|
151 |
+
|
152 |
+
.context-menu {
|
153 |
+
position: absolute;
|
154 |
+
color: white;
|
155 |
+
background: rgb(29, 31, 57);
|
156 |
+
border: 1px solid #3640f7;
|
157 |
+
border-radius: 10px;
|
158 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
159 |
+
z-index: 1000;
|
160 |
+
padding: 10px;
|
161 |
+
}
|
162 |
+
|
163 |
+
.context-menu ul {
|
164 |
+
list-style: none;
|
165 |
+
margin: 0;
|
166 |
+
padding: 0;
|
167 |
+
}
|
168 |
+
|
169 |
+
.context-menu li {
|
170 |
+
padding: 5px 10px;
|
171 |
+
cursor: pointer;
|
172 |
+
border-radius: 5px;
|
173 |
+
}
|
174 |
+
|
175 |
+
.context-menu li:hover {
|
176 |
+
background-color: #5755a2;
|
177 |
+
}
|
frontend/src/components/MoviePlayer.js
CHANGED
@@ -10,6 +10,7 @@ import {
|
|
10 |
faVolumeUp,
|
11 |
faVolumeMute,
|
12 |
faExpand,
|
|
|
13 |
} from "@fortawesome/free-solid-svg-icons";
|
14 |
import { Spinner } from "@/components/Spinner";
|
15 |
|
@@ -23,6 +24,8 @@ export default function MoviePlayer({ videoUrl, title }) {
|
|
23 |
const [showControls, setShowControls] = useState(true);
|
24 |
const [isBuffering, setIsBuffering] = useState(false);
|
25 |
const overlayTimeout = useRef(null);
|
|
|
|
|
26 |
|
27 |
useEffect(() => {
|
28 |
const videoElement = videoRef.current;
|
@@ -60,6 +63,26 @@ export default function MoviePlayer({ videoUrl, title }) {
|
|
60 |
return () => clearTimeout(overlayTimeout.current);
|
61 |
}, [showControls]);
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
const handleFastForward = () => {
|
64 |
if (videoRef.current) {
|
65 |
videoRef.current.currentTime = Math.min(
|
@@ -156,7 +179,7 @@ export default function MoviePlayer({ videoUrl, title }) {
|
|
156 |
};
|
157 |
|
158 |
return (
|
159 |
-
<div className="video-player-container" onMouseMove={handleMouseMove}>
|
160 |
<div className={`player-overlay ${showControls ? "show" : "hide"}`}>
|
161 |
<h2 className="video-title">{title}</h2>
|
162 |
<div className="controls">
|
@@ -213,10 +236,14 @@ export default function MoviePlayer({ videoUrl, title }) {
|
|
213 |
<button onClick={toggleFullscreen} className="control-btn">
|
214 |
<FontAwesomeIcon icon={faExpand} size="xl" />
|
215 |
</button>
|
|
|
|
|
|
|
|
|
|
|
216 |
</div>
|
217 |
</div>
|
218 |
</div>
|
219 |
-
{isBuffering && <div className="buffering-indicator"><Spinner/></div>}
|
220 |
</div>
|
221 |
<video
|
222 |
ref={videoRef}
|
@@ -233,6 +260,17 @@ export default function MoviePlayer({ videoUrl, title }) {
|
|
233 |
/>
|
234 |
Your browser does not support the video tag.
|
235 |
</video>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
</div>
|
237 |
);
|
238 |
}
|
|
|
10 |
faVolumeUp,
|
11 |
faVolumeMute,
|
12 |
faExpand,
|
13 |
+
faDownload,
|
14 |
} from "@fortawesome/free-solid-svg-icons";
|
15 |
import { Spinner } from "@/components/Spinner";
|
16 |
|
|
|
24 |
const [showControls, setShowControls] = useState(true);
|
25 |
const [isBuffering, setIsBuffering] = useState(false);
|
26 |
const overlayTimeout = useRef(null);
|
27 |
+
const [contextMenu, setContextMenu] = useState({ visible: false, x: 0, y: 0 });
|
28 |
+
const playerVersion = "0.0.1 Alpha";
|
29 |
|
30 |
useEffect(() => {
|
31 |
const videoElement = videoRef.current;
|
|
|
63 |
return () => clearTimeout(overlayTimeout.current);
|
64 |
}, [showControls]);
|
65 |
|
66 |
+
const handleContextMenu = (event) => {
|
67 |
+
event.preventDefault();
|
68 |
+
setContextMenu({
|
69 |
+
visible: true,
|
70 |
+
x: event.pageX,
|
71 |
+
y: event.pageY,
|
72 |
+
});
|
73 |
+
};
|
74 |
+
|
75 |
+
const hideContextMenu = () => {
|
76 |
+
setContextMenu({ visible: false, x: 0, y: 0 });
|
77 |
+
};
|
78 |
+
|
79 |
+
useEffect(() => {
|
80 |
+
window.addEventListener("click", hideContextMenu);
|
81 |
+
return () => {
|
82 |
+
window.removeEventListener("click", hideContextMenu);
|
83 |
+
};
|
84 |
+
}, []);
|
85 |
+
|
86 |
const handleFastForward = () => {
|
87 |
if (videoRef.current) {
|
88 |
videoRef.current.currentTime = Math.min(
|
|
|
179 |
};
|
180 |
|
181 |
return (
|
182 |
+
<div className="video-player-container" onMouseMove={handleMouseMove} onContextMenu={handleContextMenu}>
|
183 |
<div className={`player-overlay ${showControls ? "show" : "hide"}`}>
|
184 |
<h2 className="video-title">{title}</h2>
|
185 |
<div className="controls">
|
|
|
236 |
<button onClick={toggleFullscreen} className="control-btn">
|
237 |
<FontAwesomeIcon icon={faExpand} size="xl" />
|
238 |
</button>
|
239 |
+
{videoUrl && (
|
240 |
+
<a href={videoUrl} download className="control-btn">
|
241 |
+
<FontAwesomeIcon icon={faDownload} size="xl" />
|
242 |
+
</a>
|
243 |
+
)}
|
244 |
</div>
|
245 |
</div>
|
246 |
</div>
|
|
|
247 |
</div>
|
248 |
<video
|
249 |
ref={videoRef}
|
|
|
260 |
/>
|
261 |
Your browser does not support the video tag.
|
262 |
</video>
|
263 |
+
{isBuffering && <div className="buffering-indicator"><div className="postion-fix"><Spinner/></div></div>}
|
264 |
+
{contextMenu.visible && (
|
265 |
+
<div
|
266 |
+
className="context-menu"
|
267 |
+
style={{ left: contextMenu.x, top: contextMenu.y }}
|
268 |
+
>
|
269 |
+
<ul>
|
270 |
+
<li>Player Version: {playerVersion}</li>
|
271 |
+
</ul>
|
272 |
+
</div>
|
273 |
+
)}
|
274 |
</div>
|
275 |
);
|
276 |
}
|
frontend/src/components/Spinner.css
CHANGED
@@ -26,7 +26,7 @@
|
|
26 |
display: block;
|
27 |
width: 25%;
|
28 |
height: 25%;
|
29 |
-
background-color: rgb(
|
30 |
border-radius: 100%;
|
31 |
animation: spinner-dot-before 1.5s infinite ease-in-out both;
|
32 |
}
|
|
|
26 |
display: block;
|
27 |
width: 25%;
|
28 |
height: 25%;
|
29 |
+
background-color: rgb(74, 86, 194); /* Use a CSS variable for the color */
|
30 |
border-radius: 100%;
|
31 |
animation: spinner-dot-before 1.5s infinite ease-in-out both;
|
32 |
}
|