-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
69 lines (58 loc) · 2.08 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Array con las rutas de tus videos
const videoPaths = [
'videos/AULAS 7MO.mp4',
'videos/BAÑO.mp4',
'videos/BIBLIOTECA.mp4',
'videos/COMEDOR.mp4',
'videos/COORDINACION.mp4',
'videos/GIMNASIO.mp4',
'videos/NATATORIO.mp4',
'videos/SUBSUELO EDIFICIO 4.mp4'
];
const playButton = document.getElementById('playButton');
const videoPlayer = document.getElementById('videoPlayer');
const verRespuestaButton = document.getElementById('verRespuesta');
const siguienteButton = document.getElementById('siguiente');
let currentVideoIndex = -1;
function playRandomVideo() {
currentVideoIndex = Math.floor(Math.random() * videoPaths.length);
const randomVideoPath = videoPaths[currentVideoIndex];
videoPlayer.src = randomVideoPath;
videoPlayer.style.display = 'block';
videoPlayer.play();
playButton.style.display = 'none';
}
function showVerRespuestaButton() {
verRespuestaButton.style.display = 'block';
}
function showSiguienteButton() {
siguienteButton.style.display = 'block';
}
function hideVerRespuestaButton() {
verRespuestaButton.style.display = 'none';
}
function hideSiguienteButton() {
siguienteButton.style.display = 'none';
}
playButton.addEventListener('click', () => {
playRandomVideo();
});
videoPlayer.addEventListener('ended', () => {
showVerRespuestaButton();
showSiguienteButton();
});
verRespuestaButton.addEventListener('click', () => {
const currentVideoPath = videoPaths[currentVideoIndex];
const videoName = currentVideoPath.replace('.mp4', '');
const nombreVideo = videoName.replace('videos/', '');
const respuestaElement = document.createElement('div');
respuestaElement.textContent = `RESPUESTA: ${nombreVideo}`;
respuestaElement.classList.add('respuesta');
document.body.appendChild(respuestaElement);
hideVerRespuestaButton();
});
siguienteButton.addEventListener('click', () => {
hideVerRespuestaButton();
hideSiguienteButton();
window.location.href = 'index.html'; // Redirige a la página de inicio
});