Reputation: 2113
So my problem is this, I need to show a cover image and the actual video will be hidden. Once somebody clicks on the image, the video will become visible should start playing automatically. My code is here http://jsfiddle.net/Vq8Wr/ . This works fine in Chrome but not in any other browser. Any solution would be appreciated
the code is as follows
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<style>
.hide{
display:none
}
img{
width:500px;
}
</style>
<iframe class="hide" src="http://player.vimeo.com/video/59372982?api=1" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<img src="http://allthingsd.com/files/2011/05/clouds-1259.jpg" id="video-cover" >
<script>
$("#video-cover").click(function(){
$(this).hide();
var f = $('iframe'),
url = f.attr('src').split('?')[0];
f.show();
var data = { method: "play" };
f[0].contentWindow.postMessage(JSON.stringify(data), url);
})
</script>
Upvotes: 1
Views: 1162
Reputation: 77956
Try this instead:
.hide{
position : absolute;
left : -99999px;
}
Upvotes: 2