Skip to content

Commit

Permalink
video background support
Browse files Browse the repository at this point in the history
  • Loading branch information
14ROVI committed Dec 21, 2022
1 parent 678a292 commit 397168f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
13 changes: 13 additions & 0 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ body {
justify-content: flex-end;
}

#video-background {
position: relative;
object-fit: cover;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
z-index: -1;
}

h1 {
font-family: 'Noto Sans Display', sans-serif;
font-size: 50px;
Expand Down
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<meta charset="utf-8">
</head>
<body class="background">
<video id="video-background" autoplay muted loop></video>

<div class="main-container">
<div>
<div id="sponsors"></div>
Expand Down
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ async function displayEvents() {
function displayEvent(event) {
const now = new Date();
let body = document.body;
let videoContainer = document.getElementById("video-background");
let sponsorsContainer = document.getElementById("sponsors");
let QRCodeElement = document.getElementById("qr-code");
let eventTitleElement = document.getElementById("event-title");
Expand Down Expand Up @@ -133,7 +134,16 @@ function displayEvent(event) {
kioskOptions.background = "https://cssbristol.co.uk/assets/images/contrib/events/" + kioskOptions.background;
}

body.style.backgroundImage = `url(${kioskOptions.background}), url(default_background.png)`;
if (kioskOptions.background.match(/\.(jpg|jpeg|png|gif)$/i)) {
videoContainer.style.display = "none";
body.style.backgroundImage = `url(${kioskOptions.background}), url(default_background.png)`;
} else {
videoContainer.style.display = "";
videoContainer.innerHTML = "";
let source = document.createElement("source");
source.src = kioskOptions.background;
videoContainer.appendChild(source);
}

sponsorsContainer.innerHTML = "";
if (kioskOptions.show_sponsors) {
Expand Down

0 comments on commit 397168f

Please sign in to comment.