I'm trying to make a Rick Roll sample app, but when I use YouTube embed feature, the autoplay parameter causes the YouTube video to load showing the message "The video is unavailable". When I pass ?autoplay=0 or don't pass autoplay at all, the embed works as expected. I'm experiencing this in both Chrome and Firefox. Any thoughts on how to fix or get around this?
<!DOCTYPE html>
<html>
<body>
<button onclick="openWin()">Open "myWindow"</button>
<script>
var myWindow;
function openWin() {
myWindow=window.open("", "myWindow", "width=570, height=330");
myWindow.document.write('<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>');
myWindow.setInterval(function() {
moveWin();
}, 1000);
}
function moveWin() {
var x = getRandomNumber();
var y = getRandomNumber();
myWindow.moveTo(x, y);
myWindow.focus();
}
function getRandomNumber() {
return Math.floor(Math.random() * 500);
}
</script>
</body>
</html>