Spaces:
Sleeping
Sleeping
File size: 10,039 Bytes
19f62c1 | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TG Drive - Video Player</title>
<link href="//vjs.zencdn.net/8.3.0/video-js.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/videojs-seek-buttons/3.0.1/videojs-seek-buttons.min.css" rel="stylesheet">
<script src="//vjs.zencdn.net/8.3.0/video.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-seek-buttons/3.0.1/videojs-seek-buttons.min.js"></script>
<style>
/* Modern Reset & Base Styles */
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
font-family: 'Inter', system-ui, -apple-system, sans-serif;
background-color: #0f172a;
background-image:
radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%),
radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%),
radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
color: #ffffff;
user-select: none; /* Prevents text selection on double tap */
}
.glass-panel {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 24px;
padding: 24px;
width: 90%;
max-width: 960px;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: column;
align-items: center;
gap: 24px;
}
.video-container {
width: 100%;
border-radius: 16px;
overflow: hidden;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
position: relative; /* For double tap overlay */
}
/* --- Custom Video.js Styling --- */
/* Center Play Button */
.video-js .vjs-big-play-button {
background-color: rgba(59, 130, 246, 0.9);
border: none;
width: 80px;
height: 80px;
line-height: 80px;
border-radius: 50%;
margin-left: -40px;
margin-top: -40px;
transition: all 0.3s ease;
}
.video-js .vjs-big-play-button:hover {
background-color: #2563eb;
transform: scale(1.1);
}
/* Control Bar Transparency */
.video-js .vjs-control-bar {
background-color: rgba(15, 23, 42, 0.85);
border-radius: 0 0 16px 16px;
}
/* Seek Buttons Styling */
.video-js .vjs-seek-button {
font-size: 1.2em;
cursor: pointer;
}
/* Speed Menu Styling */
.video-js .vjs-playback-rate .vjs-playback-rate-value {
line-height: 30px;
font-weight: bold;
}
/* --- Double Tap Overlay Animation --- */
.double-tap-overlay {
position: absolute;
top: 0;
bottom: 0;
width: 40%;
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
opacity: 0;
transition: opacity 0.2s;
pointer-events: none; /* Let clicks pass through if needed, but we handle via JS */
color: rgba(255,255,255,0.8);
font-size: 40px;
}
.dt-left { left: 0; background: linear-gradient(90deg, rgba(0,0,0,0.3), transparent); }
.dt-right { right: 0; background: linear-gradient(-90deg, rgba(0,0,0,0.3), transparent); }
.dt-icon {
background: rgba(0,0,0,0.5);
border-radius: 50%;
padding: 15px;
display: none; /* Hidden by default */
}
/* Buttons Area */
.buttons-container {
display: flex;
gap: 16px;
width: 100%;
justify-content: center;
flex-wrap: wrap;
}
.copy-button {
padding: 14px 28px;
font-size: 15px;
font-weight: 600;
cursor: pointer;
background: rgba(255, 255, 255, 0.1);
color: white;
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 12px;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
min-width: 180px;
}
.copy-button:hover {
background: rgba(255, 255, 255, 0.2);
transform: translateY(-2px);
border-color: rgba(255, 255, 255, 0.4);
}
.copy-button.success {
background-color: #10b981;
border-color: #10b981;
}
</style>
</head>
<body>
<div class="glass-panel">
<div class="video-container" id="video-wrapper">
<div class="double-tap-overlay dt-left" id="dt-left">
<div class="dt-icon">⏪ 10s</div>
</div>
<div class="double-tap-overlay dt-right" id="dt-right">
<div class="dt-icon">10s ⏩</div>
</div>
<video id="my-player" class="video-js vjs-fluid vjs-big-play-centered" controls preload="auto"
data-setup='{"playbackRates": [0.5, 1, 1.25, 1.5, 2]}'>
<source id="video-src" src="" type="video/mp4">
</source>
<p class="vjs-no-js">
To view this video please enable JavaScript.
</p>
</video>
</div>
<div class="buttons-container">
<button class="copy-button" onclick="copyStreamUrl(this)">
Copy Stream URL
</button>
<button class="copy-button" onclick="copyDownloadUrl(this)">
Copy Download URL
</button>
</div>
</div>
<script>
// 1. Get URL and Set Source
const downloadUrl = (new URL(window.location.href)).searchParams.get('url');
document.getElementById('video-src').src = downloadUrl;
// 2. Initialize Video.js Features
const player = videojs('my-player');
player.ready(function() {
// Enable the Seek Buttons Plugin (Forward/Back 10s)
player.seekButtons({
forward: 10,
back: 10
});
});
// 3. Custom Double Tap Logic
const wrapper = document.getElementById('video-wrapper');
const dtLeft = document.getElementById('dt-left');
const dtRight = document.getElementById('dt-right');
let lastTapTime = 0;
// Listen for taps on the wrapper (captures clicks over the video)
wrapper.addEventListener('click', function(e) {
const currentTime = new Date().getTime();
const tapLength = currentTime - lastTapTime;
// If double tap (less than 300ms between taps)
if (tapLength < 300 && tapLength > 0) {
const rect = wrapper.getBoundingClientRect();
const x = e.clientX - rect.left; // Click position inside video
// Check if click is on Left (0-40%) or Right (60-100%) side
if (x < rect.width * 0.4) {
// Rewind
player.currentTime(player.currentTime() - 10);
showDoubleTapEffect(dtLeft);
} else if (x > rect.width * 0.6) {
// Forward
player.currentTime(player.currentTime() + 10);
showDoubleTapEffect(dtRight);
}
e.preventDefault(); // Stop default play/pause on the second click
}
lastTapTime = currentTime;
});
function showDoubleTapEffect(element) {
const icon = element.querySelector('.dt-icon');
element.style.opacity = '1';
icon.style.display = 'block';
setTimeout(() => {
element.style.opacity = '0';
setTimeout(() => { icon.style.display = 'none'; }, 200);
}, 500);
}
// 4. Clipboard Logic (Same as before)
function copyTextToClipboard(text, btnElement) {
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(() => animateButton(btnElement))
.catch(() => fallbackCopyTextToClipboard(text, btnElement));
} else {
fallbackCopyTextToClipboard(text, btnElement);
}
}
function fallbackCopyTextToClipboard(text, btnElement) {
const textArea = document.createElement('textarea');
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
try {
if (document.execCommand('copy')) animateButton(btnElement);
else alert('Failed to copy');
} catch (e) {}
document.body.removeChild(textArea);
}
function animateButton(btn) {
const originalText = btn.innerText;
btn.classList.add('success');
btn.innerText = "Copied!";
setTimeout(() => {
btn.classList.remove('success');
btn.innerText = originalText;
}, 2000);
}
function copyStreamUrl(btn) { copyTextToClipboard(window.location.href, btn); }
function copyDownloadUrl(btn) { copyTextToClipboard(downloadUrl, btn); }
</script>
</body>
</html>
|