J Z commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -399,8 +399,8 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;backgrou
|
|
| 399 |
.video-section{position:relative;width:100%;min-height:300px;max-height:45vh;background:#000;border-radius:12px;overflow:hidden;flex-shrink:0;display:flex;align-items:center;justify-content:center}
|
| 400 |
.video-container{position:relative;width:100%;height:100%}
|
| 401 |
.video-container video{width:100%;height:100%;object-fit:contain;display:block}
|
| 402 |
-
#videoA,#videoB{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:contain
|
| 403 |
-
#videoA{z-index:1
|
| 404 |
.video-status{position:absolute;bottom:8px;right:12px;font-size:.7rem;color:rgba(255,255,255,.4);background:rgba(0,0,0,.5);padding:2px 8px;border-radius:4px;z-index:10}
|
| 405 |
.chat-section{flex:1;display:flex;flex-direction:column;min-height:0;background:rgba(15,23,42,.6);border:1px solid rgba(59,130,246,.15);border-radius:12px;overflow:hidden}
|
| 406 |
.chat-log{flex:1;overflow-y:auto;padding:1rem;display:flex;flex-direction:column;gap:.5rem}
|
|
@@ -465,29 +465,40 @@ function crossfadeTo(url, muted){
|
|
| 465 |
isTransitioning=true;
|
| 466 |
const prev=getActiveVideo(), next=getInactiveVideo();
|
| 467 |
next.muted=(muted!==false);
|
| 468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 469 |
next.onloadeddata=function(){
|
| 470 |
-
|
| 471 |
next.play().then(()=>{
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
}).catch(()=>{
|
|
|
|
| 481 |
next.muted=true;
|
| 482 |
next.play().then(()=>{
|
| 483 |
-
next.style.
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
}).catch(()=>{ isTransitioning=false; resolve(); });
|
| 492 |
});
|
| 493 |
};
|
|
|
|
| 399 |
.video-section{position:relative;width:100%;min-height:300px;max-height:45vh;background:#000;border-radius:12px;overflow:hidden;flex-shrink:0;display:flex;align-items:center;justify-content:center}
|
| 400 |
.video-container{position:relative;width:100%;height:100%}
|
| 401 |
.video-container video{width:100%;height:100%;object-fit:contain;display:block}
|
| 402 |
+
#videoA,#videoB{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:contain}
|
| 403 |
+
#videoA{z-index:1}#videoB{z-index:0}
|
| 404 |
.video-status{position:absolute;bottom:8px;right:12px;font-size:.7rem;color:rgba(255,255,255,.4);background:rgba(0,0,0,.5);padding:2px 8px;border-radius:4px;z-index:10}
|
| 405 |
.chat-section{flex:1;display:flex;flex-direction:column;min-height:0;background:rgba(15,23,42,.6);border:1px solid rgba(59,130,246,.15);border-radius:12px;overflow:hidden}
|
| 406 |
.chat-log{flex:1;overflow-y:auto;padding:1rem;display:flex;flex-direction:column;gap:.5rem}
|
|
|
|
| 465 |
isTransitioning=true;
|
| 466 |
const prev=getActiveVideo(), next=getInactiveVideo();
|
| 467 |
next.muted=(muted!==false);
|
| 468 |
+
|
| 469 |
+
// Load the new video BEHIND the current one (lower z-index)
|
| 470 |
+
next.style.zIndex='0';
|
| 471 |
+
prev.style.zIndex='1';
|
| 472 |
+
next.src=url;
|
| 473 |
+
next.load();
|
| 474 |
+
|
| 475 |
next.onloadeddata=function(){
|
| 476 |
+
// Start playing while still hidden behind current video
|
| 477 |
next.play().then(()=>{
|
| 478 |
+
// Once playing, instant swap: new on top, old behind
|
| 479 |
+
next.style.zIndex='1';
|
| 480 |
+
prev.style.zIndex='0';
|
| 481 |
+
|
| 482 |
+
// Clean up old video after swap
|
| 483 |
+
prev.pause();
|
| 484 |
+
prev.removeAttribute('src');
|
| 485 |
+
prev.load(); // reset old element
|
| 486 |
+
|
| 487 |
+
currentVideo=currentVideo==='A'?'B':'A';
|
| 488 |
+
isTransitioning=false;
|
| 489 |
+
resolve();
|
| 490 |
}).catch(()=>{
|
| 491 |
+
// Autoplay blocked, retry muted
|
| 492 |
next.muted=true;
|
| 493 |
next.play().then(()=>{
|
| 494 |
+
next.style.zIndex='1';
|
| 495 |
+
prev.style.zIndex='0';
|
| 496 |
+
prev.pause();
|
| 497 |
+
prev.removeAttribute('src');
|
| 498 |
+
prev.load();
|
| 499 |
+
currentVideo=currentVideo==='A'?'B':'A';
|
| 500 |
+
isTransitioning=false;
|
| 501 |
+
resolve();
|
| 502 |
}).catch(()=>{ isTransitioning=false; resolve(); });
|
| 503 |
});
|
| 504 |
};
|