You used to be able to do this to get embedded youtube videos to automatically play in 1080p (or other qualities), however, this no longer works.
Is there another, up-to-date, way to achieve this?
You can use the iframe API found here:
https://developers.google.com/youtube/iframe_api_reference
Using the API you can specify the playback quality once the embedded video is ready as in the example below:
<div id="player"></div>
<script>
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'INSERT_VIDEO_ID_HERE',
events: {
'onReady': onPlayerReady
}
});
}
// 4. The API will call this function when the video player is ready.
// In this case we set the playback quality to 1080p
function onPlayerReady(event) {
event.target.setPlaybackQuality('hd1080')
}
</script>