Embedding and programmatically controlling multiple videos using the YouTube iframe embed API and the iframe's onload event



You can embed and programmatically control multiple YouTube videos by putting onloads like the following in (existing) iframes:
onload="player1=new YT.Player(this)"
onload="player2=new YT.Player(this)"
etc.

The names for the players (here: player 1 and player2) are arbitrarily chosen. They must be used for selecting the video for which we want to execute javascript (video) code. For instance, player2.playVideo() means that the video associated with player2 must start playing etc .

This will only work if we have this in the head:
<script src="http://www.youtube.com/player_api"></script>
and if the video-url in the iframe contains html5=1 (IE-requirement) and enablejsapi=1.

View source for further info.

Notes:
1.
The YouTube ads don't display if the width of the iframe is less than 320 pixels (the iframes to the right are 319px wide).
2.
The YouTube API reference for iframe embeds is here