<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Видео-викторина</title>
<style>
body {
margin: 0;
background: #000;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
overflow: hidden;
}
#playerContainer {
position: relative;
width: 100%;
height: 100%;
}
video {
width: 100%;
height: 100%;
object-fit: contain;
background: #000;
}
#overlay {
position: absolute;
bottom: 0;
width: 100%;
height: 80px;
background: rgba(0,0,0,0.6);
display: flex;
justify-content: center;
align-items: center;
gap: 15px;
/* Плавное появление/исчезновение */
opacity: 0;
transition: opacity 0.5s;
pointer-events: none; /* чтобы кнопки не были кликабельны, когда скрыты */
}
#overlay.show {
opacity: 1;
pointer-events: auto;
}
button {
font-size: 1.3rem;
padding: 10px 24px;
border: none;
border-radius: 12px;
cursor: pointer;
font-weight: bold;
box-shadow: 0 3px 10px rgba(0,0,0,0.3);
transition: transform 0.3s;
}
button:hover {
transform: scale(1.05);
}
#checkBtn {
background: #ffcc00; /* желтая */
color: #000;
}
#continueBtn {
background: #cccccc; /* светло-серая */
color: #000;
}
.roundBtn {
background: #333;
color: #fff;
border-radius: 50%;
width: 48px;
height: 48px;
font-size: 1.2rem;
padding: 0;
}
</style>
</head>
<body>
<div id="playerContainer">
<video id="myVideo" controls>
<source src="Viktorina-01-1.mp4" type="video/mp4">
Ваш браузер не поддерживает видео.
</video>
<div id="overlay">
<button id="checkBtn">✅ Проверить ответ</button>
<button id="continueBtn">▶ Продолжить</button>
<button id="restartBtn" class="roundBtn">⏮</button>
<button id="fullscreenBtn" class="roundBtn">⛶</button>
</div>
</div>
<script>
const container = document.getElementById("playerContainer");
const video = document.getElementById("myVideo");
const overlay = document.getElementById("overlay");
const checkBtn = document.getElementById("checkBtn");
const continueBtn = document.getElementById("continueBtn");
const restartBtn = document.getElementById("restartBtn");
const fullscreenBtn = document.getElementById("fullscreenBtn");
// исходные точки остановки
const originalCheckPoints = [14, 29, 45];
const originalContinuePoints = [];
let checkPoints = [...originalCheckPoints];
let continuePoints = [...originalContinuePoints];
video.addEventListener("timeupdate", () => {
const current = Math.floor(video.currentTime);
if (checkPoints.includes(current)) {
video.pause();
overlay.classList.add("show");
checkBtn.style.display = "inline-block";
continueBtn.style.display = "none";
checkPoints.splice(checkPoints.indexOf(current), 1);
}
if (continuePoints.includes(current)) {
video.pause();
overlay.classList.add("show");
checkBtn.style.display = "none";
continueBtn.style.display = "inline-block";
continuePoints.splice(continuePoints.indexOf(current), 1);
}
});
function hideOverlay() {
overlay.classList.remove("show");
}
checkBtn.addEventListener("click", () => {
hideOverlay();
video.play();
});
continueBtn.addEventListener("click", () => {
hideOverlay();
video.play();
});
restartBtn.addEventListener("click", () => {
video.currentTime = 0;
checkPoints = [...originalCheckPoints];
continuePoints = [...originalContinuePoints];
hideOverlay();
video.play();
});
fullscreenBtn.addEventListener("click", () => {
if (!document.fullscreenElement) {
container.requestFullscreen();
} else {
document.exitFullscreen();
}
});
</script>
</body>
</html>