-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.html
More file actions
362 lines (326 loc) · 10.1 KB
/
player.html
File metadata and controls
362 lines (326 loc) · 10.1 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DevLog Player</title>
<style>
/* Discord-inspired dark theme */
body {
margin: 0;
padding: 0;
background-color: #2f3136; /* Discord's dark background */
color: #ffffff;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
height: 100vh;
box-sizing: border-box;
}
.header {
width: 100%;
padding: 10px;
display: flex;
justify-content: flex-end;
background-color: #202225; /* Slightly darker for header */
box-sizing: border-box;
}
.exit-button {
background-color: transparent;
border: none;
color: #b9bbbe; /* Discord's subtle text color */
font-size: 16px;
cursor: pointer;
padding: 5px 10px;
transition: color 0.3s;
appearance: none; /* Standard property */
-webkit-appearance: none; /* Vendor prefix for WebKit */
-moz-appearance: none; /* Vendor prefix for Mozilla */
}
.exit-button:hover {
color: #ffffff;
}
.content {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
padding: 20px;
box-sizing: border-box;
}
video {
width: 100%;
max-width: 480px; /* Reduced size */
height: auto;
border-radius: 8px;
background-color: #000;
}
/* Custom video controls */
.controls {
display: flex;
align-items: center;
background-color: #2f3136;
padding: 10px;
width: 100%;
max-width: 480px; /* Match the video width */
box-sizing: border-box;
margin-top: 10px;
border-radius: 0 0 8px 8px;
}
.controls button {
background: none;
border: none;
color: #b9bbbe;
font-size: 18px; /* Reduced font size */
cursor: pointer;
margin-right: 10px; /* Adjusted spacing */
transition: color 0.3s;
appearance: none; /* Standard property */
-webkit-appearance: none; /* Vendor prefix */
-moz-appearance: none; /* Vendor prefix */
}
.controls button:hover {
color: #ffffff;
}
.controls .play-pause {
font-size: 20px; /* Slightly larger for visibility */
}
.controls .mute-button,
.controls .fullscreen-button {
font-size: 16px; /* Reduced font size */
}
.controls .seek-bar-container {
flex-grow: 1;
display: flex;
align-items: center;
position: relative;
}
.controls input[type="range"] {
width: 100%;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: #4f545c;
height: 4px; /* Thinner progress bar */
border-radius: 4px;
cursor: pointer;
margin: 0 8px; /* Adjusted margin */
transition: background 0.3s;
}
.controls input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 10px; /* Smaller thumb */
height: 10px;
background: #7289da;
border-radius: 50%;
cursor: pointer;
transition: background 0.3s;
}
.controls input[type="range"]::-moz-range-thumb {
width: 10px;
height: 10px;
background: #7289da;
border: none;
border-radius: 50%;
cursor: pointer;
transition: background 0.3s;
}
.controls input[type="range"]::-ms-thumb {
width: 10px;
height: 10px;
background: #7289da;
border: none;
border-radius: 50%;
cursor: pointer;
transition: background 0.3s;
}
.controls input[type="range"]:hover {
background: #5a5e63;
}
.controls span.time {
font-size: 12px; /* Smaller time text */
color: #b9bbbe;
min-width: 40px;
text-align: center;
}
/* Tooltip for seek bar */
.tooltip {
position: absolute;
bottom: 25px; /* Adjusted position */
left: 0;
transform: translateX(-50%);
background-color: #4f545c;
color: #ffffff;
padding: 2px 4px; /* Smaller padding */
border-radius: 4px;
font-size: 10px; /* Smaller font */
display: none;
pointer-events: none;
}
</style>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"
integrity="sha512-Fo3rlrZj/k7ujTTXRN59JcCBOPfAiwFAJ/dSGghxe0VzKGEhB4tZgtTa0FhKLh7MItcuu1X9ERmOjJjRC2jrFg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
</head>
<body>
<div class="header">
<button class="exit-button" id="exitButton">Exit</button>
</div>
<div class="content">
<video id="videoPlayer">
Your browser does not support the video tag.
</video>
<div class="controls">
<button id="playPauseButton" class="play-pause" title="Play/Pause">
<i class="fas fa-play"></i>
</button>
<div class="seek-bar-container">
<span class="time" id="currentTime">0:00</span>
<input type="range" id="seekBar" value="0">
<span class="time" id="duration">0:00</span>
<span class="tooltip" id="tooltip">0:00</span>
</div>
<button id="muteButton" class="mute-button" title="Mute/Unmute">
<i class="fas fa-volume-up"></i>
</button>
<button id="fullscreenButton" class="fullscreen-button" title="Fullscreen">
<i class="fas fa-expand"></i>
</button>
</div>
</div>
<script>
const urlParams = new URLSearchParams(window.location.search);
const videoPath = urlParams.get('videoPath');
const videoElement = document.getElementById('videoPlayer');
const exitButton = document.getElementById('exitButton');
const playPauseButton = document.getElementById('playPauseButton');
const seekBar = document.getElementById('seekBar');
const currentTimeText = document.getElementById('currentTime');
const durationText = document.getElementById('duration');
const muteButton = document.getElementById('muteButton');
const fullscreenButton = document.getElementById('fullscreenButton');
const tooltip = document.getElementById('tooltip');
console.log('Video Path:', videoPath); // Debugging purpose
if (!videoPath) {
alert('No video path provided.');
throw new Error('No video path provided.');
}
// Load the video source
videoElement.src = `file://${videoPath}`;
videoElement.load();
// Handle video load errors
videoElement.onerror = function () {
console.error('Error loading video.');
alert('Failed to load the video. Please ensure the file exists and is a supported format.');
};
// Update duration when metadata is loaded
videoElement.addEventListener('loadedmetadata', () => {
if (isFinite(videoElement.duration)) {
durationText.textContent = formatTime(videoElement.duration);
seekBar.max = Math.floor(videoElement.duration);
} else {
durationText.textContent = '0:00';
seekBar.max = 0;
console.error('Video duration is not finite.');
}
});
// Play/Pause functionality
playPauseButton.addEventListener('click', () => {
if (videoElement.paused || videoElement.ended) {
videoElement.play();
} else {
videoElement.pause();
}
});
// Update play/pause icon based on video state
videoElement.addEventListener('play', () => {
playPauseButton.innerHTML = '<i class="fas fa-pause"></i>';
});
videoElement.addEventListener('pause', () => {
playPauseButton.innerHTML = '<i class="fas fa-play"></i>';
});
// Update seek bar and current time as the video plays
videoElement.addEventListener('timeupdate', () => {
if (isFinite(videoElement.duration)) {
seekBar.value = Math.floor(videoElement.currentTime);
currentTimeText.textContent = formatTime(videoElement.currentTime);
} else {
currentTimeText.textContent = '0:00';
}
});
// Seek video when seek bar changes
seekBar.addEventListener('input', () => {
videoElement.currentTime = seekBar.value;
});
// Mute/Unmute functionality
muteButton.addEventListener('click', () => {
videoElement.muted = !videoElement.muted;
updateMuteButton();
});
function updateMuteButton() {
if (videoElement.muted) {
muteButton.innerHTML = '<i class="fas fa-volume-mute"></i>';
muteButton.title = 'Unmute';
} else {
muteButton.innerHTML = '<i class="fas fa-volume-up"></i>';
muteButton.title = 'Mute';
}
}
// Fullscreen functionality
fullscreenButton.addEventListener('click', () => {
if (!document.fullscreenElement) {
videoElement.requestFullscreen().catch(err => {
alert(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
});
} else {
document.exitFullscreen();
}
});
// Format time in mm:ss
function formatTime(time) {
const minutes = Math.floor(time / 60);
const seconds = Math.floor(time % 60).toString().padStart(2, '0');
return `${minutes}:${seconds}`;
}
// Close window on exit button click
exitButton.addEventListener('click', () => {
window.close();
});
// Tooltip functionality for seek bar
seekBar.addEventListener('mousemove', (e) => {
const rect = seekBar.getBoundingClientRect();
const pos = (e.clientX - rect.left) / rect.width;
const time = pos * videoElement.duration;
tooltip.textContent = formatTime(time);
tooltip.style.left = `${pos * 100}%`;
tooltip.style.display = 'block';
});
seekBar.addEventListener('mouseout', () => {
tooltip.style.display = 'none';
});
document.addEventListener('keydown', (e) => {
switch (e.key) {
case ' ':
playPauseButton.click();
break;
case 'm':
case 'M':
muteButton.click();
break;
case 'f':
case 'F':
fullscreenButton.click();
break;
default:
break;
}
});
</script>
</body>
</html>