-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (23 loc) · 858 Bytes
/
Copy pathscript.js
File metadata and controls
28 lines (23 loc) · 858 Bytes
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
const uploadInput = document.querySelector("#videoUpload");
const demoVideo = document.querySelector("#demoVideo");
const uploadStatus = document.querySelector("#uploadStatus");
const hero = document.querySelector(".hero");
let activeVideoUrl = "";
uploadInput?.addEventListener("change", () => {
const file = uploadInput.files?.[0];
if (!file) return;
if (activeVideoUrl) {
URL.revokeObjectURL(activeVideoUrl);
}
activeVideoUrl = URL.createObjectURL(file);
demoVideo.src = activeVideoUrl;
demoVideo.hidden = false;
hero.classList.add("has-demo-video");
uploadStatus.textContent = `${file.name} is loaded for the live demo.`;
const play = demoVideo.play();
if (play && typeof play.catch === "function") {
play.catch(() => {
uploadStatus.textContent = `${file.name} is loaded. Tap the video to play.`;
});
}
});