Update index.html
Browse files- index.html +318 -375
index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title
|
| 7 |
<style>
|
| 8 |
body {
|
| 9 |
font-family: 'Arial', sans-serif;
|
|
@@ -11,468 +11,411 @@
|
|
| 11 |
color: #e6f1ff;
|
| 12 |
margin: 0;
|
| 13 |
padding: 20px;
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
-
|
| 16 |
-
max-width: 1000px;
|
| 17 |
-
margin: 0 auto;
|
| 18 |
-
}
|
| 19 |
h1 {
|
| 20 |
color: #64ffda;
|
| 21 |
text-align: center;
|
| 22 |
margin-bottom: 30px;
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
}
|
| 25 |
-
|
|
|
|
| 26 |
display: flex;
|
| 27 |
-
flex-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
}
|
|
|
|
| 31 |
.video-container {
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
border-radius: 8px;
|
| 36 |
-
padding: 15px;
|
| 37 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
|
| 38 |
}
|
|
|
|
| 39 |
video {
|
| 40 |
width: 100%;
|
| 41 |
-
border-radius:
|
|
|
|
| 42 |
}
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
|
| 50 |
}
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
min-height: 100px;
|
| 57 |
margin-bottom: 15px;
|
| 58 |
-
transition: all 0.3s;
|
| 59 |
-
}
|
| 60 |
-
.drop-box.highlight {
|
| 61 |
-
background-color: rgba(100, 255, 218, 0.1);
|
| 62 |
-
border-color: #ffffff;
|
| 63 |
}
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
padding: 10px;
|
| 67 |
-
margin-bottom: 8px;
|
| 68 |
-
border-radius: 4px;
|
| 69 |
display: flex;
|
| 70 |
-
justify-content: space-between;
|
| 71 |
align-items: center;
|
|
|
|
| 72 |
}
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
color: white;
|
| 77 |
-
border-radius: 4px;
|
| 78 |
-
padding: 5px 10px;
|
| 79 |
-
cursor: pointer;
|
| 80 |
-
}
|
| 81 |
-
.controls {
|
| 82 |
-
background: #112240;
|
| 83 |
-
border-radius: 8px;
|
| 84 |
-
padding: 20px;
|
| 85 |
-
margin-bottom: 20px;
|
| 86 |
-
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
|
| 87 |
-
}
|
| 88 |
-
.control-group {
|
| 89 |
-
margin-bottom: 15px;
|
| 90 |
-
}
|
| 91 |
-
label {
|
| 92 |
-
display: block;
|
| 93 |
-
margin-bottom: 5px;
|
| 94 |
color: #64ffda;
|
| 95 |
}
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
border: none;
|
| 100 |
height: 8px;
|
| 101 |
-
|
|
|
|
|
|
|
| 102 |
outline: none;
|
| 103 |
}
|
|
|
|
| 104 |
input[type="range"]::-webkit-slider-thumb {
|
| 105 |
-webkit-appearance: none;
|
| 106 |
-
width:
|
| 107 |
-
height:
|
| 108 |
background: #64ffda;
|
| 109 |
border-radius: 50%;
|
| 110 |
cursor: pointer;
|
| 111 |
}
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
button {
|
| 121 |
-
background: #
|
| 122 |
-
color: #
|
| 123 |
-
border:
|
| 124 |
padding: 10px 20px;
|
| 125 |
-
border-radius:
|
| 126 |
cursor: pointer;
|
| 127 |
font-weight: bold;
|
| 128 |
transition: all 0.3s;
|
| 129 |
}
|
|
|
|
| 130 |
button:hover {
|
| 131 |
-
background: #
|
| 132 |
-
|
| 133 |
}
|
| 134 |
-
|
|
|
|
| 135 |
display: flex;
|
| 136 |
gap: 10px;
|
| 137 |
-
|
| 138 |
}
|
|
|
|
| 139 |
.tech-decoration {
|
|
|
|
| 140 |
height: 2px;
|
| 141 |
-
background: linear-gradient(90deg, #64ffda,
|
| 142 |
margin: 20px 0;
|
| 143 |
-
position: relative;
|
| 144 |
-
}
|
| 145 |
-
.tech-decoration::after {
|
| 146 |
-
content: "";
|
| 147 |
-
position: absolute;
|
| 148 |
-
top: -3px;
|
| 149 |
-
right: 0;
|
| 150 |
-
width: 8px;
|
| 151 |
-
height: 8px;
|
| 152 |
-
background: #64ffda;
|
| 153 |
-
border-radius: 50%;
|
| 154 |
-
}
|
| 155 |
-
.hidden {
|
| 156 |
-
display: none;
|
| 157 |
}
|
| 158 |
</style>
|
| 159 |
</head>
|
| 160 |
<body>
|
|
|
|
|
|
|
| 161 |
<div class="container">
|
| 162 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
<div class="tech-decoration"></div>
|
| 165 |
|
| 166 |
-
<div class="
|
| 167 |
-
<
|
| 168 |
-
|
| 169 |
-
<
|
| 170 |
-
|
| 171 |
-
お使いのブラウザは動画をサポートしていません。
|
| 172 |
-
</video>
|
| 173 |
</div>
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
<
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
</div>
|
| 183 |
</div>
|
| 184 |
|
| 185 |
<div class="tech-decoration"></div>
|
| 186 |
|
| 187 |
-
<div class="controls">
|
| 188 |
-
<h2
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
<
|
| 192 |
-
<
|
| 193 |
-
</div>
|
| 194 |
-
|
| 195 |
-
<div class="control-group">
|
| 196 |
-
<label for="endTime">再生終了秒数 (秒)</label>
|
| 197 |
-
<input type="number" id="endTime" min="0" step="0.1">
|
| 198 |
</div>
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
<
|
| 202 |
-
<
|
| 203 |
-
<span id="volumeValue">1</span>
|
| 204 |
</div>
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
<
|
| 208 |
-
<
|
| 209 |
-
<span id="playbackRateValue">1</span>
|
| 210 |
</div>
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
<
|
| 214 |
-
|
| 215 |
-
ループ再生
|
| 216 |
-
</label>
|
| 217 |
</div>
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
<
|
| 221 |
-
<
|
| 222 |
-
<button id="stopButton">停止</button>
|
| 223 |
</div>
|
| 224 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
</div>
|
| 226 |
|
| 227 |
<script>
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
// 音声オブジェクトを保持する配列
|
| 244 |
-
let audioContext;
|
| 245 |
-
let audioBuffers = {};
|
| 246 |
-
let soundSources = [];
|
| 247 |
-
let videoDuration = 0;
|
| 248 |
-
|
| 249 |
-
// 許可された音声ファイル
|
| 250 |
-
const allowedSounds = ['p.mp3', 'a.mp3', 't.mp3', 's.mp3'];
|
| 251 |
-
|
| 252 |
-
// ドラッグ&ドロップのイベントハンドラ
|
| 253 |
-
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
| 254 |
-
dropBox.addEventListener(eventName, preventDefaults, false);
|
| 255 |
-
});
|
| 256 |
-
|
| 257 |
-
function preventDefaults(e) {
|
| 258 |
-
e.preventDefault();
|
| 259 |
-
e.stopPropagation();
|
| 260 |
-
}
|
| 261 |
-
|
| 262 |
-
['dragenter', 'dragover'].forEach(eventName => {
|
| 263 |
-
dropBox.addEventListener(eventName, highlight, false);
|
| 264 |
-
});
|
| 265 |
-
|
| 266 |
-
['dragleave', 'drop'].forEach(eventName => {
|
| 267 |
-
dropBox.addEventListener(eventName, unhighlight, false);
|
| 268 |
-
});
|
| 269 |
-
|
| 270 |
-
function highlight() {
|
| 271 |
-
dropBox.classList.add('highlight');
|
| 272 |
-
}
|
| 273 |
-
|
| 274 |
-
function unhighlight() {
|
| 275 |
-
dropBox.classList.remove('highlight');
|
| 276 |
-
}
|
| 277 |
-
|
| 278 |
-
dropBox.addEventListener('drop', handleDrop, false);
|
| 279 |
-
|
| 280 |
-
function handleDrop(e) {
|
| 281 |
-
const dt = e.dataTransfer;
|
| 282 |
-
const files = dt.files;
|
| 283 |
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
if (allowedSounds.includes(file.name)) {
|
| 290 |
-
addSound(file.name);
|
| 291 |
-
}
|
| 292 |
-
});
|
| 293 |
-
}
|
| 294 |
-
|
| 295 |
-
// 音声を追加
|
| 296 |
-
function addSound(filename) {
|
| 297 |
-
// すでに追加済みかチェック
|
| 298 |
-
if (audioBuffers[filename]) {
|
| 299 |
-
alert(`${filename} は既に追加されています`);
|
| 300 |
-
return;
|
| 301 |
-
}
|
| 302 |
|
| 303 |
-
//
|
| 304 |
-
const
|
| 305 |
-
soundItem.className = 'sound-item';
|
| 306 |
-
soundItem.innerHTML = `
|
| 307 |
-
${filename}
|
| 308 |
-
<button data-filename="${filename}">削除</button>
|
| 309 |
-
`;
|
| 310 |
-
soundList.appendChild(soundItem);
|
| 311 |
|
| 312 |
-
//
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
});
|
| 316 |
|
| 317 |
-
//
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
// リストから削除
|
| 324 |
-
const items = document.querySelectorAll('.sound-item');
|
| 325 |
-
items.forEach(item => {
|
| 326 |
-
if (item.querySelector('button').dataset.filename === filename) {
|
| 327 |
-
item.remove();
|
| 328 |
-
}
|
| 329 |
});
|
| 330 |
|
| 331 |
-
//
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
}
|
| 340 |
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
|
| 345 |
-
audioBuffers[filename] = audioBuffer;
|
| 346 |
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
}
|
| 391 |
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
}
|
| 396 |
|
| 397 |
-
//
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
video.currentTime = startTime;
|
| 402 |
-
video.playbackRate = playbackRate;
|
| 403 |
-
video.play();
|
| 404 |
-
|
| 405 |
-
// 各音声を再生
|
| 406 |
-
for (const filename in audioBuffers) {
|
| 407 |
-
playSound(filename, startTime, endTime, volume, playbackRate, loop);
|
| 408 |
-
}
|
| 409 |
-
});
|
| 410 |
-
|
| 411 |
-
// 音声を再生
|
| 412 |
-
function playSound(filename, startTime, endTime, volume, playbackRate, loop) {
|
| 413 |
-
if (!audioContext) {
|
| 414 |
-
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 415 |
}
|
| 416 |
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
const gainNode = audioContext.createGain();
|
| 422 |
-
gainNode.gain.value = volume;
|
| 423 |
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
}
|
| 436 |
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
stopAllSounds();
|
| 451 |
-
});
|
| 452 |
-
|
| 453 |
-
// 全ての音声を停止
|
| 454 |
-
function stopAllSounds() {
|
| 455 |
-
soundSources.forEach(source => {
|
| 456 |
-
try {
|
| 457 |
-
source.stop();
|
| 458 |
-
} catch (e) {
|
| 459 |
-
console.log('音声ソースは既に停止しています');
|
| 460 |
}
|
| 461 |
});
|
| 462 |
-
soundSources = [];
|
| 463 |
-
}
|
| 464 |
-
|
| 465 |
-
// 動画の再生位置が終了時間を超えたら停止
|
| 466 |
-
video.addEventListener('timeupdate', function() {
|
| 467 |
-
const endTime = parseFloat(endTimeInput.value);
|
| 468 |
-
const loop = loopCheckbox.checked;
|
| 469 |
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
stopAllSounds();
|
| 473 |
-
} else if (loop && video.currentTime >= endTime) {
|
| 474 |
-
video.currentTime = parseFloat(startTimeInput.value);
|
| 475 |
-
}
|
| 476 |
});
|
| 477 |
</script>
|
| 478 |
</body>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>音声動画プレイヤー</title>
|
| 7 |
<style>
|
| 8 |
body {
|
| 9 |
font-family: 'Arial', sans-serif;
|
|
|
|
| 11 |
color: #e6f1ff;
|
| 12 |
margin: 0;
|
| 13 |
padding: 20px;
|
| 14 |
+
display: flex;
|
| 15 |
+
flex-direction: column;
|
| 16 |
+
align-items: center;
|
| 17 |
}
|
| 18 |
+
|
|
|
|
|
|
|
|
|
|
| 19 |
h1 {
|
| 20 |
color: #64ffda;
|
| 21 |
text-align: center;
|
| 22 |
margin-bottom: 30px;
|
| 23 |
+
border-bottom: 1px solid #64ffda;
|
| 24 |
+
padding-bottom: 10px;
|
| 25 |
+
width: 100%;
|
| 26 |
}
|
| 27 |
+
|
| 28 |
+
.container {
|
| 29 |
display: flex;
|
| 30 |
+
flex-direction: column;
|
| 31 |
+
width: 100%;
|
| 32 |
+
max-width: 800px;
|
| 33 |
+
background-color: #112240;
|
| 34 |
+
border-radius: 10px;
|
| 35 |
+
padding: 20px;
|
| 36 |
+
box-shadow: 0 0 20px rgba(100, 255, 218, 0.2);
|
| 37 |
}
|
| 38 |
+
|
| 39 |
.video-container {
|
| 40 |
+
position: relative;
|
| 41 |
+
width: 100%;
|
| 42 |
+
margin-bottom: 20px;
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
+
|
| 45 |
video {
|
| 46 |
width: 100%;
|
| 47 |
+
border-radius: 5px;
|
| 48 |
+
background-color: #000;
|
| 49 |
}
|
| 50 |
+
|
| 51 |
+
.controls {
|
| 52 |
+
display: flex;
|
| 53 |
+
flex-direction: column;
|
| 54 |
+
gap: 15px;
|
| 55 |
+
margin-bottom: 20px;
|
|
|
|
| 56 |
}
|
| 57 |
+
|
| 58 |
+
.audio-controls {
|
| 59 |
+
display: flex;
|
| 60 |
+
flex-direction: column;
|
| 61 |
+
gap: 10px;
|
|
|
|
| 62 |
margin-bottom: 15px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
}
|
| 64 |
+
|
| 65 |
+
.audio-item {
|
|
|
|
|
|
|
|
|
|
| 66 |
display: flex;
|
|
|
|
| 67 |
align-items: center;
|
| 68 |
+
gap: 10px;
|
| 69 |
}
|
| 70 |
+
|
| 71 |
+
.audio-item label {
|
| 72 |
+
min-width: 50px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
color: #64ffda;
|
| 74 |
}
|
| 75 |
+
|
| 76 |
+
input[type="range"] {
|
| 77 |
+
flex-grow: 1;
|
|
|
|
| 78 |
height: 8px;
|
| 79 |
+
-webkit-appearance: none;
|
| 80 |
+
background: #1e2a47;
|
| 81 |
+
border-radius: 5px;
|
| 82 |
outline: none;
|
| 83 |
}
|
| 84 |
+
|
| 85 |
input[type="range"]::-webkit-slider-thumb {
|
| 86 |
-webkit-appearance: none;
|
| 87 |
+
width: 18px;
|
| 88 |
+
height: 18px;
|
| 89 |
background: #64ffda;
|
| 90 |
border-radius: 50%;
|
| 91 |
cursor: pointer;
|
| 92 |
}
|
| 93 |
+
|
| 94 |
+
.settings {
|
| 95 |
+
background-color: #1e2a47;
|
| 96 |
+
padding: 15px;
|
| 97 |
+
border-radius: 5px;
|
| 98 |
+
margin-bottom: 20px;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
.setting-item {
|
| 102 |
+
display: flex;
|
| 103 |
+
justify-content: space-between;
|
| 104 |
+
align-items: center;
|
| 105 |
+
margin-bottom: 10px;
|
| 106 |
}
|
| 107 |
+
|
| 108 |
+
.setting-item:last-child {
|
| 109 |
+
margin-bottom: 0;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.setting-item label {
|
| 113 |
+
color: #ccd6f6;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
input[type="number"], input[type="checkbox"], select {
|
| 117 |
+
background-color: #112240;
|
| 118 |
+
border: 1px solid #64ffda;
|
| 119 |
+
color: #e6f1ff;
|
| 120 |
+
padding: 5px;
|
| 121 |
+
border-radius: 3px;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
button {
|
| 125 |
+
background-color: #0a192f;
|
| 126 |
+
color: #64ffda;
|
| 127 |
+
border: 1px solid #64ffda;
|
| 128 |
padding: 10px 20px;
|
| 129 |
+
border-radius: 5px;
|
| 130 |
cursor: pointer;
|
| 131 |
font-weight: bold;
|
| 132 |
transition: all 0.3s;
|
| 133 |
}
|
| 134 |
+
|
| 135 |
button:hover {
|
| 136 |
+
background-color: #64ffda;
|
| 137 |
+
color: #0a192f;
|
| 138 |
}
|
| 139 |
+
|
| 140 |
+
.buttons {
|
| 141 |
display: flex;
|
| 142 |
gap: 10px;
|
| 143 |
+
justify-content: center;
|
| 144 |
}
|
| 145 |
+
|
| 146 |
.tech-decoration {
|
| 147 |
+
width: 100%;
|
| 148 |
height: 2px;
|
| 149 |
+
background: linear-gradient(90deg, transparent, #64ffda, transparent);
|
| 150 |
margin: 20px 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
}
|
| 152 |
</style>
|
| 153 |
</head>
|
| 154 |
<body>
|
| 155 |
+
<h1>音声動画プレイヤー</h1>
|
| 156 |
+
|
| 157 |
<div class="container">
|
| 158 |
+
<div class="video-container">
|
| 159 |
+
<video id="video" muted>
|
| 160 |
+
<source src="v.mp4" type="video/mp4">
|
| 161 |
+
</video>
|
| 162 |
+
</div>
|
| 163 |
|
| 164 |
<div class="tech-decoration"></div>
|
| 165 |
|
| 166 |
+
<div class="settings">
|
| 167 |
+
<h2>設定</h2>
|
| 168 |
+
<div class="setting-item">
|
| 169 |
+
<label for="start-time">再生開始秒数:</label>
|
| 170 |
+
<input type="number" id="start-time" min="0" value="0" step="0.1">
|
|
|
|
|
|
|
| 171 |
</div>
|
| 172 |
+
<div class="setting-item">
|
| 173 |
+
<label for="end-time">再生終了秒数:</label>
|
| 174 |
+
<input type="number" id="end-time" min="0" value="0" step="0.1">
|
| 175 |
+
</div>
|
| 176 |
+
<div class="setting-item">
|
| 177 |
+
<label for="loop">ループ再生:</label>
|
| 178 |
+
<input type="checkbox" id="loop">
|
| 179 |
+
</div>
|
| 180 |
+
<div class="setting-item">
|
| 181 |
+
<label for="playback-rate">再生速度:</label>
|
| 182 |
+
<select id="playback-rate">
|
| 183 |
+
<option value="0.25">0.25x</option>
|
| 184 |
+
<option value="0.5">0.5x</option>
|
| 185 |
+
<option value="0.75">0.75x</option>
|
| 186 |
+
<option value="1" selected>1x</option>
|
| 187 |
+
<option value="1.25">1.25x</option>
|
| 188 |
+
<option value="1.5">1.5x</option>
|
| 189 |
+
<option value="2">2x</option>
|
| 190 |
+
<option value="3">3x</option>
|
| 191 |
+
</select>
|
| 192 |
+
</div>
|
| 193 |
+
<div class="setting-item">
|
| 194 |
+
<label for="global-volume">全体音量係数:</label>
|
| 195 |
+
<input type="range" id="global-volume" min="0" max="3" step="0.1" value="1">
|
| 196 |
+
<span id="global-volume-value">1</span>
|
| 197 |
</div>
|
| 198 |
</div>
|
| 199 |
|
| 200 |
<div class="tech-decoration"></div>
|
| 201 |
|
| 202 |
+
<div class="audio-controls">
|
| 203 |
+
<h2>音声コントロール</h2>
|
| 204 |
+
<div class="audio-item">
|
| 205 |
+
<label>p.mp3</label>
|
| 206 |
+
<input type="range" class="volume-slider" data-audio="p" min="0" max="1" step="0.01" value="1">
|
| 207 |
+
<span class="volume-value">1</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
</div>
|
| 209 |
+
<div class="audio-item">
|
| 210 |
+
<label>a.mp3</label>
|
| 211 |
+
<input type="range" class="volume-slider" data-audio="a" min="0" max="1" step="0.01" value="1">
|
| 212 |
+
<span class="volume-value">1</span>
|
|
|
|
| 213 |
</div>
|
| 214 |
+
<div class="audio-item">
|
| 215 |
+
<label>t.mp3</label>
|
| 216 |
+
<input type="range" class="volume-slider" data-audio="t" min="0" max="1" step="0.01" value="1">
|
| 217 |
+
<span class="volume-value">1</span>
|
|
|
|
| 218 |
</div>
|
| 219 |
+
<div class="audio-item">
|
| 220 |
+
<label>s.mp3</label>
|
| 221 |
+
<input type="range" class="volume-slider" data-audio="s" min="0" max="1" step="0.01" value="1">
|
| 222 |
+
<span class="volume-value">1</span>
|
|
|
|
|
|
|
| 223 |
</div>
|
| 224 |
+
<div class="audio-item">
|
| 225 |
+
<label>k.mp3</label>
|
| 226 |
+
<input type="range" class="volume-slider" data-audio="k" min="0" max="1" step="0.01" value="1">
|
| 227 |
+
<span class="volume-value">1</span>
|
|
|
|
| 228 |
</div>
|
| 229 |
</div>
|
| 230 |
+
|
| 231 |
+
<div class="tech-decoration"></div>
|
| 232 |
+
|
| 233 |
+
<div class="buttons">
|
| 234 |
+
<button id="play-btn">再生</button>
|
| 235 |
+
<button id="pause-btn">一時停止</button>
|
| 236 |
+
<button id="stop-btn">停止</button>
|
| 237 |
+
</div>
|
| 238 |
</div>
|
| 239 |
|
| 240 |
<script>
|
| 241 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 242 |
+
// 要素を取得
|
| 243 |
+
const video = document.getElementById('video');
|
| 244 |
+
const playBtn = document.getElementById('play-btn');
|
| 245 |
+
const pauseBtn = document.getElementById('pause-btn');
|
| 246 |
+
const stopBtn = document.getElementById('stop-btn');
|
| 247 |
+
const startTimeInput = document.getElementById('start-time');
|
| 248 |
+
const endTimeInput = document.getElementById('end-time');
|
| 249 |
+
const loopCheckbox = document.getElementById('loop');
|
| 250 |
+
const playbackRateSelect = document.getElementById('playback-rate');
|
| 251 |
+
const globalVolumeSlider = document.getElementById('global-volume');
|
| 252 |
+
const globalVolumeValue = document.getElementById('global-volume-value');
|
| 253 |
+
const volumeSliders = document.querySelectorAll('.volume-slider');
|
| 254 |
+
const volumeValues = document.querySelectorAll('.volume-value');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
|
| 256 |
+
// 音声オブジェクトを作成
|
| 257 |
+
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 258 |
+
const audioBuffers = {};
|
| 259 |
+
const audioSources = {};
|
| 260 |
+
const gainNodes = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
|
| 262 |
+
// 音声ファイル名の配列
|
| 263 |
+
const audioFiles = ['p', 'a', 't', 's', 'k'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
+
// 初期化
|
| 266 |
+
let videoDuration = 0;
|
| 267 |
+
let isPlaying = false;
|
|
|
|
| 268 |
|
| 269 |
+
// 動画のメタデータが読み込まれたら
|
| 270 |
+
video.addEventListener('loadedmetadata', function() {
|
| 271 |
+
videoDuration = video.duration;
|
| 272 |
+
endTimeInput.value = videoDuration.toFixed(1);
|
| 273 |
+
endTimeInput.max = videoDuration;
|
| 274 |
+
startTimeInput.max = videoDuration - 0.1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
});
|
| 276 |
|
| 277 |
+
// 音声ファイルを読み込む
|
| 278 |
+
function loadAudioFiles() {
|
| 279 |
+
audioFiles.forEach(file => {
|
| 280 |
+
fetch(`${file}.mp3`)
|
| 281 |
+
.then(response => response.arrayBuffer())
|
| 282 |
+
.then(arrayBuffer => audioContext.decodeAudioData(arrayBuffer))
|
| 283 |
+
.then(audioBuffer => {
|
| 284 |
+
audioBuffers[file] = audioBuffer;
|
| 285 |
+
gainNodes[file] = audioContext.createGain();
|
| 286 |
+
gainNodes[file].gain.value = 1;
|
| 287 |
+
})
|
| 288 |
+
.catch(error => console.error(`Error loading ${file}.mp3:`, error));
|
| 289 |
+
});
|
| 290 |
}
|
| 291 |
|
| 292 |
+
// 再生関数
|
| 293 |
+
function playMedia() {
|
| 294 |
+
if (isPlaying) return;
|
|
|
|
|
|
|
| 295 |
|
| 296 |
+
const startTime = parseFloat(startTimeInput.value) || 0;
|
| 297 |
+
let endTime = parseFloat(endTimeInput.value) || videoDuration;
|
| 298 |
+
const loop = loopCheckbox.checked;
|
| 299 |
+
const playbackRate = parseFloat(playbackRateSelect.value);
|
| 300 |
+
const globalVolume = parseFloat(globalVolumeSlider.value);
|
| 301 |
+
|
| 302 |
+
// 終了時間が動画の長さを超えないように
|
| 303 |
+
endTime = Math.min(endTime, videoDuration);
|
| 304 |
+
|
| 305 |
+
// 動画を設定
|
| 306 |
+
video.currentTime = startTime;
|
| 307 |
+
video.playbackRate = playbackRate;
|
| 308 |
+
video.muted = true;
|
| 309 |
+
|
| 310 |
+
// 音声を再生
|
| 311 |
+
audioFiles.forEach(file => {
|
| 312 |
+
if (audioBuffers[file]) {
|
| 313 |
+
// 既存のソースがあれば停止
|
| 314 |
+
if (audioSources[file]) {
|
| 315 |
+
audioSources[file].stop();
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
const source = audioContext.createBufferSource();
|
| 319 |
+
source.buffer = audioBuffers[file];
|
| 320 |
+
|
| 321 |
+
// ボリュームスライダーの値を取得
|
| 322 |
+
const volumeSlider = document.querySelector(`.volume-slider[data-audio="${file}"]`);
|
| 323 |
+
const volume = parseFloat(volumeSlider.value) * globalVolume;
|
| 324 |
+
|
| 325 |
+
// ゲインノードを設定
|
| 326 |
+
gainNodes[file].gain.value = volume;
|
| 327 |
+
|
| 328 |
+
// 接続
|
| 329 |
+
source.connect(gainNodes[file]);
|
| 330 |
+
gainNodes[file].connect(audioContext.destination);
|
| 331 |
+
|
| 332 |
+
// 再生
|
| 333 |
+
source.start(0, startTime, endTime - startTime);
|
| 334 |
+
|
| 335 |
+
// ループ設定
|
| 336 |
+
source.loop = loop;
|
| 337 |
+
if (loop) {
|
| 338 |
+
source.loopStart = startTime;
|
| 339 |
+
source.loopEnd = endTime;
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
audioSources[file] = source;
|
| 343 |
+
}
|
| 344 |
+
});
|
| 345 |
+
|
| 346 |
+
// 動画を再生
|
| 347 |
+
video.play();
|
| 348 |
+
isPlaying = true;
|
| 349 |
+
|
| 350 |
+
// 終了時間に達したら停止
|
| 351 |
+
video.ontimeupdate = function() {
|
| 352 |
+
if (video.currentTime >= endTime) {
|
| 353 |
+
if (!loop) {
|
| 354 |
+
stopMedia();
|
| 355 |
+
} else {
|
| 356 |
+
video.currentTime = startTime;
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
};
|
| 360 |
}
|
| 361 |
|
| 362 |
+
// 一時停止関数
|
| 363 |
+
function pauseMedia() {
|
| 364 |
+
if (!isPlaying) return;
|
| 365 |
+
|
| 366 |
+
video.pause();
|
| 367 |
+
audioFiles.forEach(file => {
|
| 368 |
+
if (audioSources[file]) {
|
| 369 |
+
audioSources[file].stop();
|
| 370 |
+
audioSources[file] = null;
|
| 371 |
+
}
|
| 372 |
+
});
|
| 373 |
+
|
| 374 |
+
isPlaying = false;
|
| 375 |
}
|
| 376 |
|
| 377 |
+
// 停止関数
|
| 378 |
+
function stopMedia() {
|
| 379 |
+
pauseMedia();
|
| 380 |
+
video.currentTime = parseFloat(startTimeInput.value) || 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
}
|
| 382 |
|
| 383 |
+
// イベントリスナーを設定
|
| 384 |
+
playBtn.addEventListener('click', playMedia);
|
| 385 |
+
pauseBtn.addEventListener('click', pauseMedia);
|
| 386 |
+
stopBtn.addEventListener('click', stopMedia);
|
|
|
|
|
|
|
| 387 |
|
| 388 |
+
// ボリュームスライダーのイベント
|
| 389 |
+
volumeSliders.forEach((slider, index) => {
|
| 390 |
+
slider.addEventListener('input', function() {
|
| 391 |
+
const value = parseFloat(this.value);
|
| 392 |
+
volumeValues[index].textContent = value.toFixed(2);
|
| 393 |
+
|
| 394 |
+
if (isPlaying && audioSources[this.dataset.audio] && gainNodes[this.dataset.audio]) {
|
| 395 |
+
const globalVolume = parseFloat(globalVolumeSlider.value);
|
| 396 |
+
gainNodes[this.dataset.audio].gain.value = value * globalVolume;
|
| 397 |
+
}
|
| 398 |
+
});
|
| 399 |
+
});
|
| 400 |
|
| 401 |
+
// 全体音量スライダーのイベント
|
| 402 |
+
globalVolumeSlider.addEventListener('input', function() {
|
| 403 |
+
const value = parseFloat(this.value);
|
| 404 |
+
globalVolumeValue.textContent = value.toFixed(1);
|
| 405 |
+
|
| 406 |
+
if (isPlaying) {
|
| 407 |
+
audioFiles.forEach(file => {
|
| 408 |
+
if (gainNodes[file]) {
|
| 409 |
+
const volumeSlider = document.querySelector(`.volume-slider[data-audio="${file}"]`);
|
| 410 |
+
const volume = parseFloat(volumeSlider.value) * value;
|
| 411 |
+
gainNodes[file].gain.value = volume;
|
| 412 |
+
}
|
| 413 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 414 |
}
|
| 415 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
|
| 417 |
+
// 初期化
|
| 418 |
+
loadAudioFiles();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
});
|
| 420 |
</script>
|
| 421 |
</body>
|