SO: Autoplay embedded Youtube video with Fancybox

http://stackoverflow.com/questions/5159047

by Marcel

HTML

<script src="http://fancybox.net/js/fancybox-1.3.4/jquery.fancybox-1.3.4.js"></script>
<link rel="stylesheet" href="http://fancybox.net/js/fancybox-1.3.4/jquery.fancybox-1.3.4.css">
<h1>Playing YouTube links in FancyBox</h1>
<p>YouTube: <a class="yt" href="http://www.youtube.com/watch?v=Sw0ihnuvIKI&amp;autoplay=1">Falling key in slow motion</a></p>

CSS

body { color:#222; font:.8125em/1.4 'segoe ui', sans-serif; }
h1 { margin:0 0 .6em; letter-spacing:-.05em; font:700 3em/1.15 'myriad pro', sans-serif; }
a { color:#36c; }

JavaScript

$(".yt").click(function(e) {
    $.fancybox({
            'padding' : 0,
            'type' : 'swf',
            'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'swf' : { 'wmode' : 'transparent', 'allowfullscreen' : 'true' }
        });
    e.preventDefault();
});