Spaces:
Running
Running
Update youtube.html
Browse files- youtube.html +54 -24
youtube.html
CHANGED
|
@@ -700,33 +700,55 @@ document.addEventListener('visibilitychange', () => {
|
|
| 700 |
}
|
| 701 |
});
|
| 702 |
|
| 703 |
-
|
| 704 |
-
document.getElementById('player-overlay').style.display = 'block'; rebuildPlayerDOM();
|
| 705 |
-
if (document.documentElement.requestFullscreen) { document.documentElement.requestFullscreen().catch(e=>{}); }
|
| 706 |
-
if (screen.orientation && screen.orientation.lock) { screen.orientation.lock('landscape').catch(e=>{}); }
|
| 707 |
-
|
| 708 |
-
ytPlayer = new YT.Player('player-target', {
|
| 709 |
-
playerVars: { autoplay: 1, rel: 0, modestbranding: 1 },
|
| 710 |
-
events: { 'onReady': (e) => { e.target.loadPlaylist(idArray); }, 'onStateChange': handleIframeStateChange }
|
| 711 |
-
});
|
| 712 |
-
}
|
| 713 |
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 719 |
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 729 |
}
|
|
|
|
|
|
|
|
|
|
| 730 |
|
| 731 |
async function handleIframeStateChange(event) {
|
| 732 |
if (event.data === YT.PlayerState.PLAYING && ytPlayer) {
|
|
@@ -1073,6 +1095,14 @@ window.addEventListener('DOMContentLoaded', () => {
|
|
| 1073 |
ytPlayer.seekTo(ytPlayer.getCurrentTime() + 10, true);
|
| 1074 |
break;
|
| 1075 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1076 |
});
|
| 1077 |
</script>
|
| 1078 |
</body>
|
|
|
|
| 700 |
}
|
| 701 |
});
|
| 702 |
|
| 703 |
+
// --- CORE PLAYER ENGINE (UPDATED WITH DELAY HACK) ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 704 |
|
| 705 |
+
function startMultiplePlayback(idArray) {
|
| 706 |
+
document.getElementById('player-overlay').style.display = 'block';
|
| 707 |
+
rebuildPlayerDOM();
|
| 708 |
+
|
| 709 |
+
// 1. Force fullscreen and orientation lock FIRST
|
| 710 |
+
if (document.documentElement.requestFullscreen) { document.documentElement.requestFullscreen().catch(e=>{}); }
|
| 711 |
+
if (screen.orientation && screen.orientation.lock) { screen.orientation.lock('landscape').catch(e=>{}); }
|
| 712 |
+
|
| 713 |
+
// 2. Wait 300ms for that specific device to finish rotating BEFORE spawning the iframe
|
| 714 |
+
setTimeout(() => {
|
| 715 |
+
ytPlayer = new YT.Player('player-target', {
|
| 716 |
+
playerVars: { autoplay: 1, rel: 0, modestbranding: 1 },
|
| 717 |
+
events: { 'onReady': (e) => { e.target.loadPlaylist(idArray); }, 'onStateChange': handleIframeStateChange }
|
| 718 |
+
});
|
| 719 |
+
}, 300);
|
| 720 |
+
}
|
| 721 |
|
| 722 |
+
function playVid(safeData) {
|
| 723 |
+
const data = JSON.parse(decodeURIComponent(safeData));
|
| 724 |
+
currentVideoData = data;
|
| 725 |
+
document.getElementById('player-overlay').style.display = 'block';
|
| 726 |
+
rebuildPlayerDOM();
|
| 727 |
+
|
| 728 |
+
// 1. Force fullscreen and orientation lock FIRST
|
| 729 |
+
if (document.documentElement.requestFullscreen) { document.documentElement.requestFullscreen().catch(e=>{}); }
|
| 730 |
+
if (screen.orientation && screen.orientation.lock) { screen.orientation.lock('landscape').catch(e=>{}); }
|
| 731 |
+
|
| 732 |
+
// 2. Wait 300ms for the DOM to settle and the screen to rotate
|
| 733 |
+
setTimeout(() => {
|
| 734 |
+
const startSec = data.timeWatched ? Math.floor(data.timeWatched) : 0;
|
| 735 |
+
lastSavedTime = -1; // Reset memory logic on new video
|
| 736 |
+
|
| 737 |
+
if (data.type === 'playlist' && data.id) {
|
| 738 |
+
ytPlayer = new YT.Player('player-target', {
|
| 739 |
+
playerVars: { listType: 'playlist', list: data.id, rel: 0, modestbranding: 1 },
|
| 740 |
+
events: { 'onReady': (e) => { e.target.playVideo(); }, 'onStateChange': handleIframeStateChange }
|
| 741 |
+
});
|
| 742 |
+
} else {
|
| 743 |
+
ytPlayer = new YT.Player('player-target', {
|
| 744 |
+
videoId: data.id,
|
| 745 |
+
playerVars: { start: startSec, autoplay: 1, rel: 0, modestbranding: 1 },
|
| 746 |
+
events: { 'onReady': (e) => { e.target.playVideo(); }, 'onStateChange': handleIframeStateChange }
|
| 747 |
+
});
|
| 748 |
}
|
| 749 |
+
startSavingHistory();
|
| 750 |
+
}, 300);
|
| 751 |
+
}
|
| 752 |
|
| 753 |
async function handleIframeStateChange(event) {
|
| 754 |
if (event.data === YT.PlayerState.PLAYING && ytPlayer) {
|
|
|
|
| 1095 |
ytPlayer.seekTo(ytPlayer.getCurrentTime() + 10, true);
|
| 1096 |
break;
|
| 1097 |
}
|
| 1098 |
+
});
|
| 1099 |
+
window.addEventListener('resize', () => {
|
| 1100 |
+
const playerOverlay = document.getElementById('player-overlay');
|
| 1101 |
+
if (playerOverlay.style.display === 'block') {
|
| 1102 |
+
// Force exact pixel height instead of relying on vh/vw
|
| 1103 |
+
playerOverlay.style.height = window.innerHeight + 'px';
|
| 1104 |
+
playerOverlay.style.width = window.innerWidth + 'px';
|
| 1105 |
+
}
|
| 1106 |
});
|
| 1107 |
</script>
|
| 1108 |
</body>
|