You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
video-player/public/main.js

40 lines
1.1 KiB
JavaScript

async function main() {
const response = await fetch('/videos');
const videos = await response.json();
const videoDiv = document.getElementById('videos');
const overlayVideoDiv = document.getElementById('overlayvideos');
videoDiv.innerHTML = '';
overlayVideoDiv.innerHTML = '';
console.log(videoDiv);
for (const video of videos) {
const button = document.createElement('button');
button.textContent = video.name;
button.addEventListener('click', () => {
fetch(`/play?video=${video.path}`, { method: 'POST' });
});
console.log(button)
videoDiv.appendChild(button);
const overlayButton = document.createElement('button');
overlayButton.textContent = video.name;
overlayButton.addEventListener('click', () => {
fetch(`/select?video=${video.path}`, { method: 'POST' });
});
overlayVideoDiv.appendChild(overlayButton);
}
const res = await fetch('/projectorstatus');
const status = await res.json();
const status1 = document.getElementById('projectorstatus1');
const status2 = document.getElementById('projectorstatus2');
status1.textContent = status.status1;
status2.textContent = status.status2;
}
main();