I'm trying to put a video as a background video on my website. I've researched a lot and it is not working and I don't know why.
On my html I have:
<video id="bgVideo" controls preload="true" autoplay loop muted>
<source src="../images/Home_Page.mp4" type="video/mp4" >
<source src="../images/Home_Page.ogv" type="video/ogg" >
<source src="../images/Home_Page.webm" type="video/webm" >
</video>
<script src="scripts/html5ext.js" type="text/javascript"></script>
And on my CSS I have:
body
{
background: url("../images/Home_Page.png") no-repeat fixed center;
}
video#bgVideo {
position: fixed;
right: 0;
bottom: 0;
width: auto;
min-width: 100%;
height: auto;
min-height: 100%;
z-index: -100;
background-size: cover;
}
However, the video is not playing and the background stays white. Any suggestions to solve this problem??
Thank you so much
This should work
<video id="bgVideo" controls preload="true" autoplay loop muted>
<source src="Home_Page.mp4" type="video/mp4" />
<source src="Home_Page.ogv" type="video/ogv" />
<source src="Home_Page.webm" type="video/webm" />
</video>
Also, you should create a htaccess file/amend your htaccess file to include the following
AddType video/mp4 .mp4 .m4v
AddType video/ogg .ogv
AddType video/webm .webm
a helpful tutorial for doing this is here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With