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 ! Les cookies que nous utilisons servent à améliorer votre expérience sur notre site et à des fins d'analyse et de marketing telles que la personnalisation des annonces. Nous ne les plaçons que si vous nous en donnez l'autorisation.
Cookie Policy