soiz1 commited on
Commit
a370b76
·
verified ·
1 Parent(s): 187e44c

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +39 -9
index.html CHANGED
@@ -443,6 +443,20 @@
443
  .audio-only-mode .controls {
444
  margin-top: 0;
445
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  </style>
447
  </head>
448
 
@@ -643,6 +657,7 @@
643
  <track id="subtitleTrackElement" kind="subtitles" src="v.vtt" srclang="ja" label="日本語" default>
644
  </track>
645
  </video>
 
646
  <div class="custom-controls">
647
  <div class="progress-container" id="progressContainer">
648
  <div class="progress-bar" id="progressBar">
@@ -692,6 +707,7 @@
692
  const subtitleTrackElement = document.getElementById('subtitleTrackElement');
693
  const videoContainer = document.querySelector('.video-container');
694
  const controls = document.querySelector('.controls');
 
695
 
696
  // 初期設定
697
  video.controls = false;
@@ -704,22 +720,32 @@ const previewVideo = document.getElementById("previewVideo");
704
  previewVideo.src = video.src;
705
  previewVideo.preload = "auto";
706
 
 
707
  progressContainer.addEventListener("mousemove", (e) => {
708
  if (!video.duration) return;
709
 
710
  const rect = progressContainer.getBoundingClientRect();
711
- const hoverTimeSec = (e.clientX - rect.left) / rect.width * video.duration;
 
712
 
713
- // プレビュー用video設定
 
 
 
 
 
 
 
714
  previewVideo.currentTime = hoverTimeSec;
715
  previewVideo.style.display = "block";
716
  previewVideo.style.left = `${e.clientX - 80}px`; // 中央揃え調整
717
- previewVideo.style.top = `${rect.top - 100}px`; // 上に配置(必要に応じて調整)
 
 
 
 
 
718
  });
719
-
720
- progressContainer.addEventListener('mouseleave', () => {
721
- hoverTime.style.display = 'none';
722
- });
723
 
724
 
725
  function updatePlaybackRate(value) {
@@ -963,8 +989,12 @@ progressContainer.addEventListener("mousemove", (e) => {
963
  document.addEventListener('webkitfullscreenchange', updateSubtitleScaleForFullscreen);
964
  document.addEventListener('mozfullscreenchange', updateSubtitleScaleForFullscreen);
965
  document.addEventListener('MSFullscreenChange', updateSubtitleScaleForFullscreen);
966
-
967
- video.addEventListener('loadedmetadata', () => {
 
 
 
 
968
  updatePlaybackRate(speedRange.value);
969
  updateVolume(volumeRange.value);
970
  updateSubtitleSize(subtitleSize.value);
 
443
  .audio-only-mode .controls {
444
  margin-top: 0;
445
  }
446
+ /* プレビュー用スタイル */
447
+ .preview-video {
448
+ position: absolute;
449
+ width: 160px;
450
+ height: 90px;
451
+ bottom: 40px;
452
+ left: 0;
453
+ background: #000;
454
+ border: 2px solid #00aaff;
455
+ box-shadow: 0 0 10px rgba(0, 170, 255, 0.5);
456
+ display: none;
457
+ pointer-events: none;
458
+ z-index: 10;
459
+ }
460
  </style>
461
  </head>
462
 
 
657
  <track id="subtitleTrackElement" kind="subtitles" src="v.vtt" srclang="ja" label="日本語" default>
658
  </track>
659
  </video>
660
+ <video id="previewVideo" class="preview-video"></video>
661
  <div class="custom-controls">
662
  <div class="progress-container" id="progressContainer">
663
  <div class="progress-bar" id="progressBar">
 
707
  const subtitleTrackElement = document.getElementById('subtitleTrackElement');
708
  const videoContainer = document.querySelector('.video-container');
709
  const controls = document.querySelector('.controls');
710
+ const previewVideo = document.getElementById("previewVideo");
711
 
712
  // 初期設定
713
  video.controls = false;
 
720
  previewVideo.src = video.src;
721
  previewVideo.preload = "auto";
722
 
723
+ // プログレスバーのホバーイベントを更新
724
  progressContainer.addEventListener("mousemove", (e) => {
725
  if (!video.duration) return;
726
 
727
  const rect = progressContainer.getBoundingClientRect();
728
+ const pos = (e.clientX - rect.left) / rect.width;
729
+ const hoverTimeSec = pos * video.duration;
730
 
731
+ // 時間表示
732
+ const minutes = Math.floor(hoverTimeSec / 60);
733
+ const seconds = Math.floor(hoverTimeSec % 60).toString().padStart(2, '0');
734
+ hoverTime.textContent = `${minutes}:${seconds}`;
735
+ hoverTime.style.display = 'block';
736
+ hoverTime.style.left = `${e.clientX - rect.left}px`;
737
+
738
+ // プレビュー表示
739
  previewVideo.currentTime = hoverTimeSec;
740
  previewVideo.style.display = "block";
741
  previewVideo.style.left = `${e.clientX - 80}px`; // 中央揃え調整
742
+ previewVideo.style.bottom = "40px"; // プログレスバーの上に表示
743
+ });
744
+
745
+ progressContainer.addEventListener('mouseleave', () => {
746
+ hoverTime.style.display = 'none';
747
+ previewVideo.style.display = 'none';
748
  });
 
 
 
 
749
 
750
 
751
  function updatePlaybackRate(value) {
 
989
  document.addEventListener('webkitfullscreenchange', updateSubtitleScaleForFullscreen);
990
  document.addEventListener('mozfullscreenchange', updateSubtitleScaleForFullscreen);
991
  document.addEventListener('MSFullscreenChange', updateSubtitleScaleForFullscreen);
992
+
993
+
994
+ // メイン動画のソースをプレビュー用にも設定
995
+ video.addEventListener('loadedmetadata', () => {
996
+ previewVideo.src = video.src;
997
+ previewVideo.preload = "auto";
998
  updatePlaybackRate(speedRange.value);
999
  updateVolume(volumeRange.value);
1000
  updateSubtitleSize(subtitleSize.value);