window.onload = function fillVideo(){
const WIDE_VIEWPORT = 520;
const wideViewport = window.matchMedia(`(min-width: ${WIDE_VIEWPORT}px)`);
const MIN_DOWNLINK = 1;
function resizeVideo(wideViewport) {
let videos = document.querySelectorAll('[data-element="hero-video"]');
videos.forEach(videoEl => {
let src = videoEl.dataset.srcMobile;
let poster = videoEl.dataset.posterMobile;
if (wideViewport.matches) {
src = videoEl.dataset.srcDesktop;
poster = videoEl.dataset.posterDesktop;
}
let downlink = MIN_DOWNLINK;
try {
downlink = navigator.connection.downlink;
} catch (e) {
console.log(`Unable to determine downlink`);
}
if (videoEl.src !== src) {
if (downlink >= MIN_DOWNLINK) {
videoEl.src = src;
videoEl.poster = poster;
console.log(`Detected bandwidth (${downlink}Mbps) greater than threshold (${MIN_DOWNLINK}Mbps) - showing video`);
} else {
videoEl.poster = poster;
console.log(`Not showing video due to low bandwidth`);
}
}
});
}
wideViewport.addListener(resizeVideo);
resizeVideo(wideViewport);}
function toggleMute() {
var video=document.getElementById("video");
var mutebutton = document.getElementById("mute");
video.muted = !video.muted;
if(mutebutton.classList.contains("fa-volume-slash")){
mutebutton.classList.replace("fa-volume-slash", "fa-volume");
}
else{
mutebutton.classList.replace("fa-volume", "fa-volume-slash");
}
}
COOKIES! De cookies die we gebruiken dienen om jouw ervaring op onze site te verbeteren en voor analytische en marketingdoeleinden zoals het personaliseren van advertenties. We plaatsen ze alleen wanneer jij toestemming geeft.
Cookie Policy