YouTube iFrame API “setPlaybackQuality” or “suggestedQuality” not working

I have the exact same problem and workaround.
I think what’s happening is that YouTube is only allowing quality levels based on the actual size of the display, so unless you have your video 720px tall you can’t default to 720p before it’s actually playing. Then the user controls kick in and YouTube stops being a dick.

EDIT

Just hit a breakthrough:
If you use event 3 (buffering) instead of event 5 (playing) there’s no stutter for the user. Quality is changed as soon as it starts loading. Only weird thing is you need to set it in onPlayerReady as well or it doesn’t work.

function onPlayerReady(event) {
    event.target.setPlaybackQuality('hd720');
}
function onPlayerStateChange(event) {
    if (event.data == YT.PlayerState.BUFFERING) {
        event.target.setPlaybackQuality('hd720');
    }
}

Leave a Comment