Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
videooverlay v2.html
<div style="width:100%; height:100%; clear:both; position:absolute; top: 0; left: 0; z-index:99; overflow:hidden;" id="video-layer">
<iframe id="player1" src="http://player.vimeo.com/video/72242208?api=1&player_id=player1&title=0&byline=0&portrait=0" width="1200" height="675" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen style="min-height: 100%; max-height: 100%; min-width: 100%; max-width: 100%; width: 100%; height: 100%; position: absolute; z-index: 50;"></iframe>
<a class="video-link" href="#" style="position: absolute; z-index: 55; bottom: 10%; left: 10%; color: #fff;">Skip Video</a>
</div>
<script type="text/javascript">
(function ($) {
"use strict";
var iframe = $('#player1')[0],
player = $f(iframe);
// Helper object to test for mobile devices.
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
// Helper functions to set and read cookies.
function createCookie(name,value,days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
}
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
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(nameEQ) == 0) { 
return c.substring(nameEQ.length,c.length);
}
}
return null;
}
function onFinish(id) {
$('.frontpage-wrapper').attr('style', 'visible');
$('#video-layer').detach();
createCookie('scopevideo4','played',1);
}
$(document).ready(function() {
var playedStatus = readCookie('scopevideo35');
if (Modernizr.postmessage && playedStatus !== 'played' && document.documentMode != 7) {
$('.frontpage-wrapper').attr('style', 'visibility: hidden;');
$('.video-link').bind('click', function (event) {
event.preventDefault();
onFinish();
});
// When the player is ready, add listeners for pause, finish, and playProgress
player.addEvent('ready', function() {
player.addEvent('finish', onFinish);
if (!isMobile.any()) {
player.api('play');
window.setTimeout(player.api('play'), 3000);
}
});
} else {
$('#video-layer').remove();
}
});
})(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.