I am trying to embed a YouTube HD video, but no matter what I try, it only ever downloads the 480p version.
According to YouTube, embedding HD videos is as simple as adding hd=1 to the URL:
<iframe src="//www.youtube.com/embed/{videoId}?hd=1" width="960" height="720" frameborder="0" allowfullscreen></iframe>
This, however, does not seem to work, at least in my iframe implementation:
<iframe id="video-player" width="960" height="720" src="//www.youtube.com/embed/{videoId}?enablejsapi=1&autoplay=1&rel=0&modestbranding=1&showinfo=0&showsearch=0" frameborder="0" allowfullscreen></iframe>
The same can be said for the Javascript API:
HTML:
<div id="video-player"></div>
JS:
var player; function onYouTubePlayerAPIReady() { player = new YT.Player('video-player', { height: '720', width: '960', videoId: '{videoId}', playerVars: { 'controls': 1, 'autoplay': 1, 'hd': 1 }, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerStateChange } }); } function onPlayerReady(event) { player.playVideo(); }
youtube youtube-api iframe embed
Chad Levy Nov 08 2018-11-11T00: 00Z
source share