Update index.html
Browse files- index.html +28 -19
index.html
CHANGED
@@ -417,6 +417,11 @@
|
|
417 |
|
418 |
<script>
|
419 |
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
|
|
|
|
|
|
420 |
// 要素を取得
|
421 |
const video = document.getElementById('video');
|
422 |
const videoContainer = document.getElementById('video-container');
|
@@ -465,7 +470,11 @@
|
|
465 |
startTimeInput.max = videoDuration - 0.1;
|
466 |
updateTimeDisplay();
|
467 |
});
|
468 |
-
|
|
|
|
|
|
|
|
|
469 |
// 時間表示を更新
|
470 |
function updateTimeDisplay() {
|
471 |
const currentTime = video.currentTime;
|
@@ -671,24 +680,24 @@
|
|
671 |
}
|
672 |
|
673 |
// 音声ファイルを読み込む
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
|
693 |
// 音声を再生
|
694 |
function playAudio(file, startTime) {
|
|
|
417 |
|
418 |
<script>
|
419 |
document.addEventListener('DOMContentLoaded', function() {
|
420 |
+
// SoundTouchJSを動的にインポート
|
421 |
+
if (!window.soundtouch) {
|
422 |
+
soundtouch = await import('https://cdn.jsdelivr.net/npm/[email protected]/dist/soundtouch.min.js');
|
423 |
+
window.soundtouch = soundtouch;
|
424 |
+
}
|
425 |
// 要素を取得
|
426 |
const video = document.getElementById('video');
|
427 |
const videoContainer = document.getElementById('video-container');
|
|
|
470 |
startTimeInput.max = videoDuration - 0.1;
|
471 |
updateTimeDisplay();
|
472 |
});
|
473 |
+
document.getElementById('play-pause-btn').addEventListener('click', function() {
|
474 |
+
if (audioContext.state === 'suspended') {
|
475 |
+
audioContext.resume();
|
476 |
+
}
|
477 |
+
});
|
478 |
// 時間表示を更新
|
479 |
function updateTimeDisplay() {
|
480 |
const currentTime = video.currentTime;
|
|
|
680 |
}
|
681 |
|
682 |
// 音声ファイルを読み込む
|
683 |
+
function loadAudioFiles() {
|
684 |
+
audioFiles.forEach(file => {
|
685 |
+
fetch(`${file}.mp3`)
|
686 |
+
.then(response => response.arrayBuffer())
|
687 |
+
.then(arrayBuffer => audioContext.decodeAudioData(arrayBuffer))
|
688 |
+
.then(audioBuffer => {
|
689 |
+
audioBuffers[file] = audioBuffer;
|
690 |
+
gainNodes[file] = audioContext.createGain();
|
691 |
+
gainNodes[file].gain.value = 1;
|
692 |
+
|
693 |
+
// SoundTouchノードを作成
|
694 |
+
soundTouchNodes[file] = new window.soundtouch.SoundTouch(audioBuffer.sampleRate);
|
695 |
+
soundTouchNodes[file].tempo = currentPlaybackRate;
|
696 |
+
soundTouchNodes[file].pitch = 1;
|
697 |
+
})
|
698 |
+
.catch(error => console.error(`Error loading ${file}.mp3:`, error));
|
699 |
+
});
|
700 |
+
}
|
701 |
|
702 |
// 音声を再生
|
703 |
function playAudio(file, startTime) {
|