Spaces:
Running
Running
Update index.html
Browse files- index.html +100 -15
index.html
CHANGED
@@ -799,21 +799,87 @@
|
|
799 |
}
|
800 |
hideContextMenu();
|
801 |
}
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
817 |
// 字幕関連の関数
|
818 |
function toggleSubtitles() {
|
819 |
subtitlesEnabled = !subtitlesEnabled;
|
@@ -1048,10 +1114,29 @@
|
|
1048 |
|
1049 |
// 復元
|
1050 |
window.addEventListener('load', () => {
|
|
|
|
|
1051 |
const savedTime = parseFloat(localStorage.getItem('radioTaisoTime'));
|
1052 |
if (!isNaN(savedTime)) {
|
1053 |
video.currentTime = savedTime;
|
1054 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1055 |
});
|
1056 |
document.addEventListener('keydown', (e) => {
|
1057 |
if (e.target.tagName === 'INPUT') return; // 入力中は無視
|
|
|
799 |
}
|
800 |
hideContextMenu();
|
801 |
}
|
802 |
+
function setupFullscreenContextMenu() {
|
803 |
+
const fullscreenElement = document.fullscreenElement ||
|
804 |
+
document.webkitFullscreenElement ||
|
805 |
+
document.msFullscreenElement;
|
806 |
+
|
807 |
+
if (fullscreenElement) {
|
808 |
+
fullscreenElement.addEventListener('contextmenu', showContextMenu);
|
809 |
+
}
|
810 |
+
}
|
811 |
+
function updateSubtitleScaleForFullscreen() {
|
812 |
+
if (document.fullscreenElement || document.webkitFullscreenElement ||
|
813 |
+
document.mozFullScreenElement || document.msFullscreenElement) {
|
814 |
+
// 全画面モード
|
815 |
+
const fullscreenWidth = window.innerWidth;
|
816 |
+
const scaleFactor = fullscreenWidth / normalVideoWidth;
|
817 |
+
document.documentElement.style.setProperty('--fullscreen-scale', scaleFactor);
|
818 |
+
|
819 |
+
// 全画面要素にイベントリスナーを追加
|
820 |
+
const fsElement = document.fullscreenElement || document.webkitFullscreenElement ||
|
821 |
+
document.mozFullScreenElement || document.msFullscreenElement;
|
822 |
+
fsElement.addEventListener('contextmenu', showContextMenu);
|
823 |
+
} else {
|
824 |
+
// 通常モード
|
825 |
+
document.documentElement.style.setProperty('--fullscreen-scale', 1);
|
826 |
+
}
|
827 |
+
}
|
828 |
+
function setupFramePreview() {
|
829 |
+
let previewTimeout;
|
830 |
+
|
831 |
+
progressContainer.addEventListener('mousemove', (e) => {
|
832 |
+
if (!videoBlob || !video.duration) return;
|
833 |
+
|
834 |
+
clearTimeout(previewTimeout);
|
835 |
+
|
836 |
+
const progressRect = progressContainer.getBoundingClientRect();
|
837 |
+
const clickX = Math.max(0, Math.min(e.clientX - progressRect.left, progressRect.width));
|
838 |
+
const previewTime = (clickX / progressRect.width) * video.duration;
|
839 |
+
|
840 |
+
// 時間表示を更新
|
841 |
+
const previewMinutes = Math.floor(previewTime / 60);
|
842 |
+
const previewSeconds = Math.floor(previewTime % 60).toString().padStart(2, '0');
|
843 |
+
frameTime.textContent = `${previewMinutes}:${previewSeconds}`;
|
844 |
+
|
845 |
+
// プレビュー位置を更新
|
846 |
+
framePreview.style.left = `${e.clientX - 80}px`; // 中央寄せ
|
847 |
+
framePreview.style.display = 'block';
|
848 |
+
|
849 |
+
// キャッシュがあればそれを使う
|
850 |
+
const cacheKey = Math.floor(previewTime);
|
851 |
+
if (frameCache[cacheKey]) {
|
852 |
+
previewImage.src = frameCache[cacheKey];
|
853 |
+
return;
|
854 |
+
}
|
855 |
+
|
856 |
+
// フレームを取得
|
857 |
+
VideoForThumbnail.currentTime = previewTime;
|
858 |
+
|
859 |
+
VideoForThumbnail.addEventListener('seeked', function() {
|
860 |
+
canvas.width = VideoForThumbnail.videoWidth;
|
861 |
+
canvas.height = VideoForThumbnail.videoHeight;
|
862 |
+
ctx.drawImage(VideoForThumbnail, 0, 0, canvas.width, canvas.height);
|
863 |
+
const imageData = canvas.toDataURL('image/jpeg');
|
864 |
+
previewImage.src = imageData;
|
865 |
+
frameCache[cacheKey] = imageData; // キャッシュに保存
|
866 |
+
}, { once: true });
|
867 |
+
});
|
868 |
+
|
869 |
+
progressContainer.addEventListener('mouseleave', () => {
|
870 |
+
previewTimeout = setTimeout(() => {
|
871 |
+
framePreview.style.display = 'none';
|
872 |
+
}, 300);
|
873 |
+
});
|
874 |
+
|
875 |
+
framePreview.addEventListener('mouseenter', () => {
|
876 |
+
clearTimeout(previewTimeout);
|
877 |
+
});
|
878 |
+
|
879 |
+
framePreview.addEventListener('mouseleave', () => {
|
880 |
+
framePreview.style.display = 'none';
|
881 |
+
});
|
882 |
+
}
|
883 |
// 字幕関連の関数
|
884 |
function toggleSubtitles() {
|
885 |
subtitlesEnabled = !subtitlesEnabled;
|
|
|
1114 |
|
1115 |
// 復元
|
1116 |
window.addEventListener('load', () => {
|
1117 |
+
setupFramePreview();
|
1118 |
+
setupFullscreenContextMenu();
|
1119 |
const savedTime = parseFloat(localStorage.getItem('radioTaisoTime'));
|
1120 |
if (!isNaN(savedTime)) {
|
1121 |
video.currentTime = savedTime;
|
1122 |
}
|
1123 |
+
|
1124 |
+
document.addEventListener('fullscreenchange', () => {
|
1125 |
+
updateSubtitleScaleForFullscreen();
|
1126 |
+
setupFullscreenContextMenu();
|
1127 |
+
});
|
1128 |
+
document.addEventListener('webkitfullscreenchange', () => {
|
1129 |
+
updateSubtitleScaleForFullscreen();
|
1130 |
+
setupFullscreenContextMenu();
|
1131 |
+
});
|
1132 |
+
document.addEventListener('mozfullscreenchange', () => {
|
1133 |
+
updateSubtitleScaleForFullscreen();
|
1134 |
+
setupFullscreenContextMenu();
|
1135 |
+
});
|
1136 |
+
document.addEventListener('MSFullscreenChange', () => {
|
1137 |
+
updateSubtitleScaleForFullscreen();
|
1138 |
+
setupFullscreenContextMenu();
|
1139 |
+
});
|
1140 |
});
|
1141 |
document.addEventListener('keydown', (e) => {
|
1142 |
if (e.target.tagName === 'INPUT') return; // 入力中は無視
|