-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
48 lines (42 loc) · 1.24 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
// Get video and text elements
const video = document.getElementById("background-video");
const enterPage = document.getElementById("enter-page");
const mainPage = document.getElementById("main-page");
// Try to play with sound first
video.muted = false;
// Add error handling for video
video.addEventListener('error', function(e) {
console.error('Error loading video:', e);
});
// Function to attempt playing video
async function attemptPlay() {
try {
// Try to play with sound
await video.play();
console.log('Playing with sound');
} catch (err) {
console.log('Autoplay with sound failed, falling back to muted');
// If it fails, mute and try again
video.muted = true;
try {
await video.play();
console.log('Playing muted');
} catch (err) {
console.error('Both autoplay attempts failed:', err);
}
}
}
// Add loading check
video.addEventListener('loadeddata', function() {
console.log('Video loaded successfully');
attemptPlay();
});
// Force video load if needed
video.load();
// Add a click event listener to the Enter Page
enterPage.addEventListener("click", () => {
// Hide the Enter Page
enterPage.style.display = "none";
// Show the Main Page
mainPage.style.display = "flex";
});