34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
$(document).ready(function () {
|
|
function setVideoDroneQuality() {
|
|
$sourceElement = $("#video-source");
|
|
|
|
const videoSources = {
|
|
fullHD: 'static/home/video/drone-background-video-1080p.mp4', // For desktops (1920x1080)
|
|
hd: 'static/home/video/drone-background-video-720p.mp4', // For tablets/smaller screens (1280x720)
|
|
lowRes: 'static/home/video/drone-background-video-480p.mp4' // For mobile devices or low performance (854x480)
|
|
};
|
|
|
|
const screenWidth = $(window).width(); // Get screen width
|
|
|
|
// Determine the appropriate video source
|
|
if (screenWidth >= 1920) {
|
|
$sourceElement.attr('src', "https://vontor-cz.s3.eu-central-1.amazonaws.com/" + videoSources.fullHD);
|
|
} else if (screenWidth >= 1280) {
|
|
$sourceElement.attr('src', "https://vontor-cz.s3.eu-central-1.amazonaws.com/" + videoSources.hd);
|
|
} else {
|
|
$sourceElement.attr('src', "https://vontor-cz.s3.eu-central-1.amazonaws.com/" + videoSources.lowRes);
|
|
}
|
|
|
|
// Reload the video
|
|
$('#drone-video')[0].load();
|
|
|
|
console.log("video set!");
|
|
|
|
}
|
|
|
|
setTimeout(1000);
|
|
|
|
setVideoDroneQuality();
|
|
//$("#debug-drone").click(setVideoDroneQuality);
|
|
});
|