soiz1 commited on
Commit
2bbe980
·
1 Parent(s): a845ee9

Update index.html

Browse files
Files changed (1) hide show
  1. 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
- // 音声の再生速度を変更 (SoundTouchJSが音の高さを保持)
646
  audioFiles.forEach(file => {
647
- if (soundTouchNodes[file]) {
648
- soundTouchNodes[file].tempo = speed;
649
  }
650
  });
651
  }
@@ -677,25 +677,19 @@
677
  }
678
  }
679
 
680
- // 音声ファイルを読み込む
681
- function loadAudioFiles() {
682
- audioFiles.forEach(file => {
683
- fetch(`${file}.mp3`)
684
- .then(response => response.arrayBuffer())
685
- .then(arrayBuffer => audioContext.decodeAudioData(arrayBuffer))
686
- .then(audioBuffer => {
687
- audioBuffers[file] = audioBuffer;
688
- gainNodes[file] = audioContext.createGain();
689
- gainNodes[file].gain.value = 1;
690
-
691
- // SoundTouchノードを作成
692
- soundTouchNodes[file] = new window.soundtouch.SoundTouch(audioBuffer.sampleRate);
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
- function pauseMedia() {
755
- if (!isPlaying) return;
756
-
757
- video.pause();
758
- audioFiles.forEach(file => {
759
- if (audioSources[file]) {
760
- try {
761
- audioSources[file].source.stop();
762
- audioSources[file].processor.disconnect();
763
- } catch(e) {
764
- console.log("Audio source already stopped");
765
- }
766
- audioSources[file] = null;
767
- }
768
- });
769
-
770
- isPlaying = false;
771
- isVideoPlaying = false;
772
- playPauseBtn.textContent = '▶';
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;