Spaces:
Sleeping
Sleeping
Update static/index.html
Browse files- static/index.html +49 -37
static/index.html
CHANGED
|
@@ -421,43 +421,55 @@
|
|
| 421 |
const wrap = document.createElement('div');
|
| 422 |
wrap.className = 'media';
|
| 423 |
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 461 |
const img = document.createElement('img');
|
| 462 |
img.src = it.src; img.alt = it.title || '';
|
| 463 |
// Click image to close that popup
|
|
|
|
| 421 |
const wrap = document.createElement('div');
|
| 422 |
wrap.className = 'media';
|
| 423 |
|
| 424 |
+
if (it.type === 'video') {
|
| 425 |
+
wrap.setAttribute('data-kind','video'); // reserve space
|
| 426 |
+
|
| 427 |
+
const v = document.createElement('video');
|
| 428 |
+
v.autoplay = true; v.loop = true; v.muted = true; v.playsInline = true;
|
| 429 |
+
v.crossOrigin = 'anonymous';
|
| 430 |
+
v.style.width = '100%'; v.style.height = 'auto';
|
| 431 |
+
|
| 432 |
+
let hlsInst = null;
|
| 433 |
+
if (window.Hls && window.Hls.isSupported() && /\.m3u8($|\?)/i.test(it.src)) {
|
| 434 |
+
hlsInst = new Hls();
|
| 435 |
+
hlsInst.loadSource(it.src);
|
| 436 |
+
hlsInst.attachMedia(v);
|
| 437 |
+
hlsInst.on(Hls.Events.MANIFEST_PARSED, () => { v.play().catch(()=>{}); });
|
| 438 |
+
} else {
|
| 439 |
+
const srcEl = document.createElement('source');
|
| 440 |
+
srcEl.src = it.src;
|
| 441 |
+
const mime = guessVideoMime(it.src); if (mime) srcEl.type = mime;
|
| 442 |
+
v.appendChild(srcEl);
|
| 443 |
+
v.load();
|
| 444 |
+
v.play().catch(()=>{});
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
v.addEventListener('loadedmetadata', () => {
|
| 448 |
+
if (v.videoWidth && v.videoHeight) wrap.style.aspectRatio = (v.videoWidth / v.videoHeight).toString();
|
| 449 |
+
});
|
| 450 |
+
|
| 451 |
+
// CLOSE THIS POPUP when user clicks the small video
|
| 452 |
+
const closeSelf = (e) => {
|
| 453 |
+
e.stopPropagation();
|
| 454 |
+
it.open = false;
|
| 455 |
+
try { v.pause(); } catch {}
|
| 456 |
+
if (hlsInst) { try { hlsInst.destroy(); } catch {} }
|
| 457 |
+
renderItems();
|
| 458 |
+
};
|
| 459 |
+
// Click anywhere on the video area to close
|
| 460 |
+
wrap.addEventListener('click', closeSelf);
|
| 461 |
+
v.addEventListener('click', closeSelf);
|
| 462 |
+
|
| 463 |
+
v.addEventListener('error', () => {
|
| 464 |
+
const note = document.createElement('div');
|
| 465 |
+
note.style.padding = '10px 12px';
|
| 466 |
+
note.style.color = '#ffd2d2';
|
| 467 |
+
note.textContent = 'Video failed to load. Use MP4 (H.264/AAC), WEBM, or HLS (.m3u8).';
|
| 468 |
+
wrap.innerHTML = ''; wrap.appendChild(note);
|
| 469 |
+
}, {once:true});
|
| 470 |
+
|
| 471 |
+
wrap.appendChild(v);
|
| 472 |
+
} else {
|
| 473 |
const img = document.createElement('img');
|
| 474 |
img.src = it.src; img.alt = it.title || '';
|
| 475 |
// Click image to close that popup
|