Hacking Embedded Videos to Autoplay
As you increase your web presence, you may want to embed your YouTube videos on external pages. Perhaps you'd like to include your latest video in your new blog post or even include it on your MySpace profile. That's great, and I encourage it. Embedding your video on an external page (a page outside YouTube) gives visitors to other websites the chance to watch your video without leaving that site. However, viewers of embedded videos won't be able to rate or comment on that video, and they won't be able to subscribe from the external site, something to consider before embedding.
Embedding is fairly straightforward. YouTube provides a string of code next to each video that you can copy and paste into your blog or MySpace profile. Once it's pasted there, your video appears like magic. By default, the video appears in a YouTube player with a large Play button in the middle of the screen. For some instances, though, you may want your video to play automatically without requiring your viewers to click that Play button.
Here's how to hack the embedding code to autoplay (automatically start) your video:
Start with the default embed code, provided by YouTube:
<object width="425" height="344"><param name="movie" value="www.youtube.com/ v/717oxEOfERQ&hl=en"></param><embed src="www.youtube.com/v/717oxEOfERQ&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>
Find the video URL; it will appear in the string of code twice and will ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access