my client ask me to run a vedio as preloader. I have tried many tricks but not working properly.
I have tried many tricks but not working properly.
Add the below code in functions.php
<?php
function add_video_preloader() {
?>
<div id="preloader">
<video id="preloader-video" src="<?php echo get_template_directory_uri(); ?>/{your-video-file-name.mp4}" autoplay muted loop></video>
</div>
<?php
}
add_action( 'wp_head', 'add_video_preloader' );
?>
And add below code in theme's style.css
#preloader {
position: fixed;
z-index: 9999;
width: 100%;
height: 100%;
background-color: #ffffff;
}
#preloader-video {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
}