Update index.html
Browse files- index.html +37 -45
index.html
CHANGED
@@ -637,15 +637,15 @@
|
|
637 |
updatePlaybackRate(speed);
|
638 |
});
|
639 |
|
640 |
-
|
641 |
function updatePlaybackRate(speed) {
|
642 |
currentPlaybackRate = speed;
|
643 |
video.playbackRate = speed;
|
644 |
|
645 |
-
// 音声の再生速度を変更
|
646 |
audioFiles.forEach(file => {
|
647 |
-
if (
|
648 |
-
|
649 |
}
|
650 |
});
|
651 |
}
|
@@ -677,25 +677,19 @@
|
|
677 |
}
|
678 |
}
|
679 |
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
soundTouchNodes[file].tempo = currentPlaybackRate;
|
694 |
-
soundTouchNodes[file].pitch = 1;
|
695 |
-
})
|
696 |
-
.catch(error => console.error(`Error loading ${file}.mp3:`, error));
|
697 |
-
});
|
698 |
-
}
|
699 |
|
700 |
function playAudio(file, startTime) {
|
701 |
if (!audioBuffers[file]) return;
|
@@ -750,28 +744,26 @@
|
|
750 |
audioSources[file] = pitchShifter;
|
751 |
}
|
752 |
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
}
|
774 |
-
|
775 |
// 再生関数
|
776 |
function playMedia() {
|
777 |
const startTime = video.currentTime;
|
|
|
637 |
updatePlaybackRate(speed);
|
638 |
});
|
639 |
|
640 |
+
|
641 |
function updatePlaybackRate(speed) {
|
642 |
currentPlaybackRate = speed;
|
643 |
video.playbackRate = speed;
|
644 |
|
645 |
+
// 音声の再生速度を変更
|
646 |
audioFiles.forEach(file => {
|
647 |
+
if (audioSources[file]) {
|
648 |
+
audioSources[file].processor.tempo = speed;
|
649 |
}
|
650 |
});
|
651 |
}
|
|
|
677 |
}
|
678 |
}
|
679 |
|
680 |
+
async function loadAudioFiles() {
|
681 |
+
for (const file of audioFiles) {
|
682 |
+
try {
|
683 |
+
const response = await fetch(`${file}.mp3`);
|
684 |
+
const arrayBuffer = await response.arrayBuffer();
|
685 |
+
audioBuffers[file] = await audioContext.decodeAudioData(arrayBuffer);
|
686 |
+
gainNodes[file] = audioContext.createGain();
|
687 |
+
gainNodes[file].gain.value = 1;
|
688 |
+
} catch (error) {
|
689 |
+
console.error(`Error loading ${file}.mp3:`, error);
|
690 |
+
}
|
691 |
+
}
|
692 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
693 |
|
694 |
function playAudio(file, startTime) {
|
695 |
if (!audioBuffers[file]) return;
|
|
|
744 |
audioSources[file] = pitchShifter;
|
745 |
}
|
746 |
|
747 |
+
function pauseMedia() {
|
748 |
+
if (!isPlaying) return;
|
749 |
+
|
750 |
+
video.pause();
|
751 |
+
audioFiles.forEach(file => {
|
752 |
+
if (audioSources[file]) {
|
753 |
+
try {
|
754 |
+
audioSources[file].source.stop();
|
755 |
+
audioSources[file].processor.disconnect();
|
756 |
+
} catch (e) {
|
757 |
+
console.log("Audio source already stopped");
|
758 |
+
}
|
759 |
+
audioSources[file] = null;
|
760 |
+
}
|
761 |
+
});
|
762 |
+
|
763 |
+
isPlaying = false;
|
764 |
+
isVideoPlaying = false;
|
765 |
+
playPauseBtn.textContent = '▶';
|
766 |
+
}
|
|
|
|
|
767 |
// 再生関数
|
768 |
function playMedia() {
|
769 |
const startTime = video.currentTime;
|