Update index.html
Browse files- index.html +116 -1
index.html
CHANGED
@@ -667,7 +667,53 @@ if ('serviceWorker' in navigator) {
|
|
667 |
</div>
|
668 |
|
669 |
<h1>高度な音声動画プレイヤー</h1>
|
670 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
671 |
<div class="container">
|
672 |
<div class="video-container" id="video-container">
|
673 |
<!-- バッファリングインジケーター -->
|
@@ -884,7 +930,76 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
884 |
console.error(message, error);
|
885 |
window.alert(`${message}\n\nエラー詳細: ${error.message}`);
|
886 |
}
|
|
|
|
|
|
|
|
|
887 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
888 |
// 要素を取得
|
889 |
const video = document.getElementById('video');
|
890 |
const videoContainer = document.getElementById('video-container');
|
|
|
667 |
</div>
|
668 |
|
669 |
<h1>高度な音声動画プレイヤー</h1>
|
670 |
+
<div class="settings">
|
671 |
+
<h2>サービスワーカー設定</h2>
|
672 |
+
<div class="setting-item">
|
673 |
+
<label><input type="checkbox" id="sw-video" checked> 動画ファイル (/v.mp4)</label>
|
674 |
+
</div>
|
675 |
+
<div class="setting-item">
|
676 |
+
<label><input type="checkbox" id="sw-t-video" checked> 動画ファイル (/t/v.mp4)</label>
|
677 |
+
</div>
|
678 |
+
<div class="setting-item">
|
679 |
+
<label><input type="checkbox" id="sw-piano" checked> ピアノ音声 (/p.mp3)</label>
|
680 |
+
</div>
|
681 |
+
<div class="setting-item">
|
682 |
+
<label><input type="checkbox" id="sw-soprano" checked> ソプラノ音声 (/s.mp3)</label>
|
683 |
+
</div>
|
684 |
+
<div class="setting-item">
|
685 |
+
<label><input type="checkbox" id="sw-alto" checked> アルト音声 (/a.mp3)</label>
|
686 |
+
</div>
|
687 |
+
<div class="setting-item">
|
688 |
+
<label><input type="checkbox" id="sw-tenor" checked> テノール音声 (/t.mp3)</label>
|
689 |
+
</div>
|
690 |
+
<div class="setting-item">
|
691 |
+
<label><input type="checkbox" id="sw-combined" checked> 全体音声 (/k.mp3)</label>
|
692 |
+
</div>
|
693 |
+
<div class="setting-item">
|
694 |
+
<label><input type="checkbox" id="sw-t-piano" checked> ピアノ音声 (/t/p.mp3)</label>
|
695 |
+
</div>
|
696 |
+
<div class="setting-item">
|
697 |
+
<label><input type="checkbox" id="sw-t-soprano" checked> ソプラノ音声 (/t/s.mp3)</label>
|
698 |
+
</div>
|
699 |
+
<div class="setting-item">
|
700 |
+
<label><input type="checkbox" id="sw-t-alto" checked> アルト音声 (/t/a.mp3)</label>
|
701 |
+
</div>
|
702 |
+
<div class="setting-item">
|
703 |
+
<label><input type="checkbox" id="sw-t-tenor" checked> テノール音声 (/t/t.mp3)</label>
|
704 |
+
</div>
|
705 |
+
<div class="setting-item">
|
706 |
+
<label><input type="checkbox" id="sw-t-combined" checked> 全体音声 (/t/k.mp3)</label>
|
707 |
+
</div>
|
708 |
+
<div class="setting-item">
|
709 |
+
<label><input type="checkbox" id="sw-index" checked> インデックスファイル (/index.html)</label>
|
710 |
+
</div>
|
711 |
+
<div class="setting-item">
|
712 |
+
<label><input type="checkbox" id="sw-root" checked> ルートファイル (/)</label>
|
713 |
+
</div>
|
714 |
+
<button class="combine-button" id="sw-register-btn">登録を開始</button>
|
715 |
+
<div class="combine-status" id="sw-status"></div>
|
716 |
+
</div>
|
717 |
<div class="container">
|
718 |
<div class="video-container" id="video-container">
|
719 |
<!-- バッファリングインジケーター -->
|
|
|
930 |
console.error(message, error);
|
931 |
window.alert(`${message}\n\nエラー詳細: ${error.message}`);
|
932 |
}
|
933 |
+
|
934 |
+
// サービスワーカー登録関数
|
935 |
+
async function registerServiceWorker() {
|
936 |
+
const statusElement = document.getElementById('sw-status');
|
937 |
|
938 |
+
if (!('serviceWorker' in navigator)) {
|
939 |
+
statusElement.textContent = "このブラウザはService Workerをサポートしていません";
|
940 |
+
return;
|
941 |
+
}
|
942 |
+
|
943 |
+
try {
|
944 |
+
// チェックされたファイルを収集
|
945 |
+
const filesToCache = [];
|
946 |
+
|
947 |
+
// 基本ファイル
|
948 |
+
if (document.getElementById('sw-index').checked) filesToCache.push('/index.html');
|
949 |
+
if (document.getElementById('sw-root').checked) filesToCache.push('/');
|
950 |
+
|
951 |
+
// 通常のメディアファイル
|
952 |
+
if (document.getElementById('sw-video').checked) filesToCache.push('/v.mp4');
|
953 |
+
if (document.getElementById('sw-piano').checked) filesToCache.push('/p.mp3');
|
954 |
+
if (document.getElementById('sw-soprano').checked) filesToCache.push('/s.mp3');
|
955 |
+
if (document.getElementById('sw-alto').checked) filesToCache.push('/a.mp3');
|
956 |
+
if (document.getElementById('sw-tenor').checked) filesToCache.push('/t.mp3');
|
957 |
+
if (document.getElementById('sw-combined').checked) filesToCache.push('/k.mp3');
|
958 |
+
|
959 |
+
// t/ ディレクトリのメディアファイル
|
960 |
+
if (document.getElementById('sw-t-video').checked) filesToCache.push('/t/v.mp4');
|
961 |
+
if (document.getElementById('sw-t-piano').checked) filesToCache.push('/t/p.mp3');
|
962 |
+
if (document.getElementById('sw-t-soprano').checked) filesToCache.push('/t/s.mp3');
|
963 |
+
if (document.getElementById('sw-t-alto').checked) filesToCache.push('/t/a.mp3');
|
964 |
+
if (document.getElementById('sw-t-tenor').checked) filesToCache.push('/t/t.mp3');
|
965 |
+
if (document.getElementById('sw-t-combined').checked) filesToCache.push('/t/k.mp3');
|
966 |
+
|
967 |
+
statusElement.textContent = "サービスワーカーを登録中...";
|
968 |
+
|
969 |
+
// Service Workerを登録
|
970 |
+
const registration = await navigator.serviceWorker.register('/service-worker.js');
|
971 |
+
|
972 |
+
// Service Workerがアクティブになるのを待つ
|
973 |
+
await new Promise(resolve => {
|
974 |
+
if (registration.active) {
|
975 |
+
resolve();
|
976 |
+
} else {
|
977 |
+
registration.addEventListener('updatefound', () => {
|
978 |
+
const newWorker = registration.installing;
|
979 |
+
newWorker.addEventListener('statechange', () => {
|
980 |
+
if (newWorker.state === 'activated') {
|
981 |
+
resolve();
|
982 |
+
}
|
983 |
+
});
|
984 |
+
});
|
985 |
+
}
|
986 |
+
});
|
987 |
+
|
988 |
+
// Service Workerにキャッシュするファイルを送信
|
989 |
+
registration.active.postMessage({
|
990 |
+
type: 'CACHE_FILES',
|
991 |
+
files: filesToCache
|
992 |
+
});
|
993 |
+
|
994 |
+
statusElement.textContent = "サービスワーカーが正常に登録されました";
|
995 |
+
} catch (error) {
|
996 |
+
console.error('Service Worker登録エラー:', error);
|
997 |
+
statusElement.textContent = `サービスワーカー登録に失敗しました: ${error.message}`;
|
998 |
+
}
|
999 |
+
}
|
1000 |
+
|
1001 |
+
// 登録ボタンにイベントリスナーを追加
|
1002 |
+
document.getElementById('sw-register-btn').addEventListener('click', registerServiceWorker);
|
1003 |
// 要素を取得
|
1004 |
const video = document.getElementById('video');
|
1005 |
const videoContainer = document.getElementById('video-container');
|