I have a video embedded on an HTML page like this:
<div id="contentVideo">
<video id="video" controls autoplay preload="auto" type="video/mp4" src=<?php echo $url; ?>">
</div>
and this CSS
#video {
width:100vw;
height:100vh;
}
I have tried also
#video {
width:100%;
height:100%;
}
This video's data is read by PHP and dumped on the page, so the user will not see the video's URL.
That works fine, except for two problems:
- The video will not autoplay on safari
- The video fills a gigantic size but I want it to fill just the size of the browser.
I explain: the video is HD. Suppose the user is seen that page on a browser window that has no more of 1000x500 pixels. I want the video to scale to fit on the available window, not to display at its original size.
How do I do that with CSS/JavaScript keeping the video proportion, in a way that the video rescales if the window changes size?