YouTube AutoStart Tip
YouTube is the second largest search engine in the world - which is owned by none other than the largest search engine, Google. Volumes have been written about video optimization, but your core objective should be about the quality of each visitor experience.
I ran across this bit of code on - Web Hosting Talk this morning (OP did not list the source), where the script sets up a YouTube video to autostart only one time, then if the visitor comes back on that page, the video will not start again.
<script language=”Javascript”>
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;
date.setTime(date.getTime()+(days*24*60*60*1000));
document.cookie = “played=1″+”; expires=”+date.toGMTString()+”; path=/”;
return 0;
}
if(played()==0){
document.write(“<embed src=\”http://www.youtube.com/v/W5E2Q6PW&autoplay=1\” type=\”application/x-shockwave-flash\” wmode=\”transparent\” width=\”740\” height=\”400\”></embed>”);
}
else{
document.write(“<embed src=\”http://www.youtube.com/v/W5E2Q6PW\” type=\”application/x-shockwave-flash\” wmode=\”transparent\” width=\”740\” height=\”400\”></embed>”);
}
</script>Replace the YouTube embed with a valid URL.
Please let me know if this works for you (Or Not)





Featured Dedicated Servers