Aichatbot12321 commited on
Commit
60c86bf
·
verified ·
1 Parent(s): 6b9c8d6

Update youtube.html

Browse files
Files changed (1) hide show
  1. youtube.html +54 -24
youtube.html CHANGED
@@ -700,33 +700,55 @@ document.addEventListener('visibilitychange', () => {
700
  }
701
  });
702
 
703
- function startMultiplePlayback(idArray) {
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
- function playVid(safeData) {
715
- const data = JSON.parse(decodeURIComponent(safeData));
716
- currentVideoData = data; document.getElementById('player-overlay').style.display = 'block'; rebuildPlayerDOM();
717
- if (document.documentElement.requestFullscreen) { document.documentElement.requestFullscreen().catch(e=>{}); }
718
- if (screen.orientation && screen.orientation.lock) { screen.orientation.lock('landscape').catch(e=>{}); }
 
 
 
 
 
 
 
 
 
 
 
719
 
720
- const startSec = data.timeWatched ? Math.floor(data.timeWatched) : 0;
721
- lastSavedTime = -1; // Reset memory logic on new video
722
-
723
- if (data.type === 'playlist' && data.id) {
724
- ytPlayer = new YT.Player('player-target', { playerVars: { listType: 'playlist', list: data.id, rel: 0, modestbranding: 1 }, events: { 'onReady': (e) => { e.target.playVideo(); }, 'onStateChange': handleIframeStateChange } });
725
- } else if (data.id) {
726
- ytPlayer = new YT.Player('player-target', { videoId: data.id, playerVars: { start: startSec, autoplay: 1, rel: 0, modestbranding: 1 }, events: { 'onReady': (e) => { e.target.playVideo(); }, 'onStateChange': handleIframeStateChange } });
727
- }
728
- startSavingHistory();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>