|
Youtube autoplay
Hello i have this javascript that randomly plays youtube clips but i have been looking for what to add so the videos can autoplay, can anyone please help me? tried adding &autoplay=1 at the end of video urls but wont work
<script type="text/javascript">
function rand ( n )
{
return ( Math.floor ( Math.random ( ) * n + 1 ) );
}
// Store youtube [CHANGES NEEDED IN THE 3 URLS BELOW]
var vids = new Array ( );
vids[1] = "http://www.youtube.com/embed/WdO85Qf4Poc";
vids[2] = "http://www.youtube.com/embed/4y6CCSCQAmw";
vids[3] = "http://www.youtube.com/embed/Yp6KZyNEkcU";
// Pick a random video from the list
function pick_vid ( )
{
var numberOfImages = 3; //[CHANGE THE 3 TO THE TOTAL NUMBER OF VIDS YOU USE]
var num = rand(numberOfImages)-1;
document.getElementById("random_youtube_vid").src = vids[num];
}
</script>
|