YouTube Embed Tricks
It is important to note that you should not disable any of the functionality of the player, meaning don’t use unauthorized hacks. Here is a list of simple ways that you can legally manipulate your embed code.
A standard embed code looks something like this:
Code
<iframe title=”YouTube video player” width=”640″ height=”510″ src=”http://www.youtube.com/embed/5yle1USyhCY” frameborder=”0″ allowfullscreen></iframe>
To make the video autoplay when a person lands on your site you should add ‘&autoplay=1′ to the end of the URL. For example:
Code
<iframe title=”YouTube video player” width=”640″ height=”510″ src=”http://www.youtube.com/embed/5yle1USyhCY&autoplay=1” frameborder=”0″ allowfullscreen></iframe>
Disable the related videos that appear at the end of the video by adding ‘&rel=0′ to the end of the URL. For example:
Code
<iframe title=”YouTube video player” width=”640″ height=”510″ src=”http://www.youtube.com/embed/5yle1USyhCY&rel=0” frameborder=”0″ allowfullscreen></iframe>
To hide the search box that sometimes appears when you hover your mouse over the video add ‘&showsearch=0′ to the end of the URL. For example:
Code
<iframe title=”YouTube video player” width=”640″ height=”510″ src=”http://www.youtube.com/embed/5yle1USyhCY&showsearch=0” frameborder=”0″ allowfullscreen></iframe>
You can loop the embedded video by adding ‘&loop=1′ to the end of the URL. For example:
Code
<iframe title=”YouTube video player” width=”640″ height=”510″ src=”http://www.youtube.com/embed/5yle1USyhCY&loop=1” frameborder=”0″ allowfullscreen></iframe>
You can skip parts of the beginning by using ‘&start=30′ at the end of the URL. This would cause the video to start playing 30 seconds in. You can make that number anything you want. Here is the example:
Code
<iframe title=”YouTube video player” width=”640″ height=”510″ src=”http://www.youtube.com/embed/5yle1USyhCY&start=30” frameborder=”0″ allowfullscreen></iframe>
You can use any combination of these hacks together. The following example uses the autoplay and loop together:
Code
<iframe title=”YouTube video player” width=”640″ height=”510″ src=”http://www.youtube.com/embed/5yle1USyhCY&autoplay=1&loop=1” frameborder=”0″ allowfullscreen></iframe>