Radio-Exercise_No.1 / index.html
soiz1's picture
Update index.html
4292da4 verified
raw
history blame
4.26 kB
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>ๅ‹•็”ปใƒ—ใƒฌใ‚คใƒคใƒผ</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
background-color: #f0f0f0;
font-family: sans-serif;
padding: 20px;
}
video {
max-width: 100%;
height: auto;
margin-bottom: 10px;
}
.controls {
display: flex;
flex-direction: column;
gap: 15px;
width: 100%;
max-width: 500px;
}
.control-group {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
input[type="range"] {
flex: 1;
}
input[type="number"] {
width: 60px;
}
</style>
</head>
<body>
<h1>ใƒฉใ‚ธใ‚ชไฝ“ๆ“ๅ‹•็”ปใƒ—ใƒฌใ‚คใƒคใƒผ<br>For Kushihara</h1>
<div class="control-group">
<label for="videoSelect">ๅ‹•็”ปใฎ้Ÿณ้‡ใ‚’้ธๆŠž๏ผš</label>
<select id="videoSelect">
<option value="v.mp4">้€šๅธธ้Ÿณ้‡</option>
<option value="v-2.mp4">ๅคง้Ÿณ้‡</option>
</select>
</div>
<video id="videoPlayer" src="v.mp4" controls></video>
<div class="controls">
<div class="control-group">
<label for="speedRange">ๅ†็”Ÿ้€Ÿๅบฆ๏ผš</label>
<input type="range" id="speedRange" min="0.0001" max="5" step="0.0001" value="1">
<input type="number" id="speedInput" min="0.0001" step="0.0001" value="1">
</div>
<div class="control-group">
<label for="volumeRange">้Ÿณ้‡๏ผš</label>
<input type="range" id="volumeRange" min="0" max="1" step="0.01" value="1">
<input type="number" id="volumeInput" min="0" max="1" step="0.01" value="1">
</div>
<div class="control-group">
<label for="loopCheckbox">ใƒซใƒผใƒ—ๅ†็”Ÿ๏ผš</label>
<input type="checkbox" id="loopCheckbox" checked>
</div>
<button onclick="goFullscreen()">ๅ…จ็”ป้ข</button>
</div>
<script>
const video = document.getElementById('videoPlayer');
const videoSelect = document.getElementById('videoSelect');
const speedRange = document.getElementById('speedRange');
const speedInput = document.getElementById('speedInput');
const volumeRange = document.getElementById('volumeRange');
const volumeInput = document.getElementById('volumeInput');
const loopCheckbox = document.getElementById('loopCheckbox');
function updatePlaybackRate(value) {
const speed = parseFloat(value);
speedInput.value = speed;
speedRange.value = speed;
video.playbackRate = speed;
}
function updateVolume(value) {
const volume = parseFloat(value);
volumeInput.value = volume;
volumeRange.value = volume;
video.volume = volume;
}
function handleVideoChange() {
const selected = videoSelect.value;
if (selected === 'v-2.mp4') {
const confirmPlay = confirm("ใ“ใฎๅ‹•็”ปใฏ้Ÿณ้‡ใŒๅคงใใ„ใงใ™ใ€‚ใ‚ใ‚‰ใ‹ใ˜ใ‚ใ€ใƒ‡ใƒใ‚คใ‚นใฎ้Ÿณ้‡ใ‚’ใ‚ใ‚‹็จ‹ๅบฆไธ‹ใ’ใฆใใ ใ•ใ„ใ€‚ใพใŸใ€้Ÿณๅ‰ฒใ‚ŒใŒ่ตทใใพใ™ใ€‚ๅ†็”Ÿใ—ใฆใ‚‚ใ‚ˆใ‚ใ—ใ„ใงใ™ใ‹๏ผŸ");
if (!confirmPlay) {
videoSelect.value = video.src.split('/').pop(); // ๅ…ƒใซๆˆปใ™
return;
}
}
video.src = selected;
video.load();
video.play();
}
videoSelect.addEventListener('change', handleVideoChange);
['input', 'change', 'mouseup'].forEach(eventName => {
speedRange.addEventListener(eventName, () => updatePlaybackRate(speedRange.value));
volumeRange.addEventListener(eventName, () => updateVolume(volumeRange.value));
});
speedInput.addEventListener('input', () => updatePlaybackRate(speedInput.value));
volumeInput.addEventListener('input', () => updateVolume(volumeInput.value));
loopCheckbox.addEventListener('change', () => {
video.loop = loopCheckbox.checked;
});
function goFullscreen() {
if (video.requestFullscreen) {
video.requestFullscreen();
} else if (video.webkitRequestFullscreen) {
video.webkitRequestFullscreen();
} else if (video.msRequestFullscreen) {
video.msRequestFullscreen();
}
}
video.addEventListener('loadedmetadata', () => {
updatePlaybackRate(speedRange.value);
updateVolume(volumeRange.value);
video.loop = loopCheckbox.checked;
});
</script>
</body>
</html>