I found this gem of a code snippet today, courtesy of http://www.geekstogo.com/forum/topic/268961-video-autoplay/

I was building a website out that I wanted to autoplay a YouTube video, but I didn’t want the video to autoplay every single time the viewer hit the home page.  I knew the answer was in setting a cookie, and here’s some tasty javascript that does just that.

[sourcecode language=”javascript”]<script type="text/javascript" language="Javascript">// <![CDATA[
function played(){
var ca = document.cookie.split(‘;’);
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==’ ‘) c = c.substring(1,c.length);
if (c.indexOf("played=") == 0) return 1;
var date = new Date();
var days = 7;
document.cookie = "played=1"+"; expires="+date.toGMTString()+"; path=/";
return 0;
document.write("<embed src=\"http://www.youtube.com/v/z435EriT9eY&#038;hl&#038;autoplay=1\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"460\" height=\"340\"></embed>");
document.write("<embed src=\"http://www.youtube.com/v/z435EriT9eY&#038;hl\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"460\" height=\"340\"></embed>");
// ]]></script>[/sourcecode]

How this works, basically, is that the javascript sets a cookie.  If there is no cookie, then it writes the embed code for the YouTube video with the autoplay flag set.  If there IS a cookie, then it writes out the embed code with no autoflag in the parameters.

You can set the expiration of the cookie by changing the “var days = 1;”  to something else, like 5 days or 7 days.  I prefer to set it for just one day.

A big thanks to the person in the geekstogo forum who posted this solution.  This really made my day!