i want to embed a YouTube video into a website.
This video has a min resolution of 256 × 144 px and a max resolution of 1280 x 720 px.
I want to limit the embedded video to the given resolutions above.
I already found examples for dynamic YouTube embeds but some of them only have a min-width and if i increase the browser size beyond 1280 px width the video keeps expanding with it.
I tried to add a max-width parameter but when i resize the browser the height doesn't resize after this and the video gets chopped at the top and the bottom. which looks like a aspect ratio of 64:9 instead of 16:9.
Also some examples crop my video to a 4:3 aspect ratio, which looks terrible.
Here are the examples i found
CSS:
.video-container {
position:relative;
padding-bottom:56.25%;
padding-top:30px;
height:0;
overflow:hidden;
}
.video-container embed {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
}
HTML
<div class="video-container">
<embed src="youtube code"></embed>
</div>