85 lines
1.5 KiB
HTML
85 lines
1.5 KiB
HTML
<!doctype html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>CANCOM Simple Signage Player</title>
|
|
|
|
<style>
|
|
html, body {
|
|
margin: 0;
|
|
padding: 0;
|
|
background: black;
|
|
width: 100%;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#image, #video {
|
|
position: fixed;
|
|
inset: 0;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
object-fit: contain;
|
|
background: black;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<img id="image" hidden>
|
|
<video id="video" hidden muted autoplay playsinline></video>
|
|
|
|
<script>
|
|
const files = {{ files | tojson }};
|
|
const interval = {{ interval }} * 1000;
|
|
const screen = "{{ screen }}";
|
|
|
|
let index = 0;
|
|
let lastHash = null;
|
|
|
|
const img = document.getElementById("image");
|
|
const video = document.getElementById("video");
|
|
|
|
function isVideo(name) {
|
|
return name.toLowerCase().endsWith(".mp4");
|
|
}
|
|
|
|
function showNext() {
|
|
if (files.length === 0) return;
|
|
|
|
const file = files[index];
|
|
index = (index + 1) % files.length;
|
|
|
|
if (isVideo(file)) {
|
|
img.hidden = true;
|
|
video.hidden = false;
|
|
video.src = `/media/${screen}/${file}`;
|
|
video.load();
|
|
video.play();
|
|
} else {
|
|
video.pause();
|
|
video.hidden = true;
|
|
img.hidden = false;
|
|
img.src = `/media/${screen}/${file}`;
|
|
setTimeout(showNext, interval);
|
|
}
|
|
}
|
|
|
|
video.addEventListener("ended", showNext);
|
|
|
|
async function checkForUpdate() {
|
|
const r = await fetch(`/playlist/${screen}/hash`, { cache: "no-store" });
|
|
const hash = await r.text();
|
|
if (lastHash && hash !== lastHash) location.reload();
|
|
lastHash = hash;
|
|
}
|
|
|
|
setInterval(checkForUpdate, 5000);
|
|
showNext();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
|