soiz1 commited on
Commit
b18e52d
·
1 Parent(s): bdd9e5f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +33 -19
index.html CHANGED
@@ -1430,30 +1430,44 @@ document.getElementById('sw-register-btn').addEventListener('click', registerSer
1430
  updateVolumeIcon();
1431
  }
1432
 
1433
- // 再生速度を適用(ピッチ維持)
1434
- function applyPlaybackRate() {
1435
- if (!isAudioCombined) return;
 
 
 
 
 
 
 
1436
 
1437
- const speed = parseFloat(playbackSpeedSlider.value);
1438
- currentPlaybackRate = speed;
1439
- video.playbackRate = speed;
 
1440
 
1441
- if (combinedAudioSource) {
1442
- combinedAudioSource.playbackRate.value = speed;
1443
- // ピッチを維持する設定
1444
- if ('preservesPitch' in combinedAudioSource) {
1445
- combinedAudioSource.preservesPitch = true;
1446
- } else if ('webkitPreservesPitch' in combinedAudioSource) {
1447
- combinedAudioSource.webkitPreservesPitch = true;
1448
- } else if ('mozPreservesPitch' in combinedAudioSource) {
1449
- combinedAudioSource.mozPreservesPitch = true;
1450
- }
1451
  }
1452
 
1453
- speedValue.textContent = speed.toFixed(2) + 'x';
1454
- playbackSpeedValue.textContent = speed.toFixed(2) + 'x';
1455
- speedSlider.value = speed;
 
 
 
 
1456
  }
 
 
 
 
 
1457
  document.addEventListener('visibilitychange', function() {
1458
  if (document.hidden) {
1459
  // タブが非アクティブになったら同期チェックを停止
 
1430
  updateVolumeIcon();
1431
  }
1432
 
1433
+ function applyPlaybackRate() {
1434
+ if (!isAudioCombined) return;
1435
+
1436
+ const speed = parseFloat(playbackSpeedSlider.value);
1437
+ currentPlaybackRate = speed;
1438
+ video.playbackRate = speed;
1439
+
1440
+ if (combinedAudioSource) {
1441
+ // 既存のオーディオソースを停止
1442
+ combinedAudioSource.stop();
1443
 
1444
+ // 新しいオーディオソースを作成
1445
+ combinedAudioSource = audioContext.createBufferSource();
1446
+ combinedAudioSource.buffer = combinedAudioBuffer;
1447
+ combinedAudioSource.connect(audioContext.destination);
1448
 
1449
+ // ピッチ維持設定を一度だけ行う
1450
+ if ('preservesPitch' in combinedAudioSource) {
1451
+ combinedAudioSource.preservesPitch = true;
1452
+ } else if ('webkitPreservesPitch' in combinedAudioSource) {
1453
+ combinedAudioSource.webkitPreservesPitch = true;
1454
+ } else if ('mozPreservesPitch' in combinedAudioSource) {
1455
+ combinedAudioSource.mozPreservesPitch = true;
 
 
 
1456
  }
1457
 
1458
+ // 再生速度を設定
1459
+ combinedAudioSource.playbackRate.value = speed;
1460
+
1461
+ // 再生中なら新しいソースで再生を続ける
1462
+ if (isPlaying) {
1463
+ combinedAudioSource.start(0, video.currentTime);
1464
+ }
1465
  }
1466
+
1467
+ speedValue.textContent = speed.toFixed(2) + 'x';
1468
+ playbackSpeedValue.textContent = speed.toFixed(2) + 'x';
1469
+ speedSlider.value = speed;
1470
+ }
1471
  document.addEventListener('visibilitychange', function() {
1472
  if (document.hidden) {
1473
  // タブが非アクティブになったら同期チェックを停止