Actually… It seems the setQuality() only works if the video/stream has already started playing, so the only way to set a different quality (from what the user has saved as a cookie) is to do:
if(event.event == "videoPlaying") {
var player = $("#twitch_embed_player")[0];
<?php if(!empty($userdata["quality"])){ ?>
player.setQuality('<?php echo($userdata["quality"]); ?>');
<?php } else { ?>
player.setQuality('Source');
<?php } ?>
}
Sadly enough, no way (afaik) to set quality before the stream loads. At first I thought: OK not a big deal, we just load the “Low” quality first, and then upgrade if this is a saved user preference… But nope. Default is whatever the user selected last, there is no way to read this, and if it’s Source, the player will first load Source, and then downgrade (load again…).