I just solved this problem for a website I was working on.
I have embedded iframes with youtube videos in them and they, annoyingly, auto-played at a low resolution despite my wanting them to auto-play at 720p. This issue is caused by the actual size of the video, on your page, being detected by YouTube which will trigger an auto-selection of a lower res.
Here's what I did to keep my video embed small, but have it auto play on 720p etc -
- You need to add ?vq=hd720 at the end of your video id, as you have done.
- Manually set the iframe width to width="1280" height="720" - which will make the video huge on your site.
- Wrap the iframe in a div and give it a class selector so you can style it with css.
- Use CSS to tell your div wrapper to be the size you actually want the video to be.
- Use CSS to set the iframe width:100% and height:100%.
This code will basically set the video size to be that of the resolution you want it to auto-play on, which will trick YouTube into setting this for you. Then the CSS dynamically resizes the video to be whatever actual size you need.
And that's all there is to it :)
CODE EXAMPLE:
HTML
CSS
.youtube-embed {
width : 740px;
height : 400px;
}
.youtube-embed iframe {
width : 100%;
height : 100%;
}