pyc-website

main website for pyc inc.

git clone https://9o.is/git/pyc-website.git

IntroVideo.js

(1930B)


      1 angular.module("IntroVideo", [])
      2   
      3 .controller('IntroVideoCtrl', ['$scope', function($scope) {		
      4 	
      5 	$scope.current = 0;
      6 	var intervals = [1,4,6.5,9,11];
      7 	
      8 	var navbar_height = 80;
      9 	var videow = document.getElementById("intro-content");
     10 	var videobg = document.getElementById("bgvid");
     11 	
     12 	videow.setAttribute("style", "height:" + (window.innerHeight - navbar_height) + "px");
     13 	videobg.setAttribute("style", "height:" + (window.innerHeight - navbar_height) + "px");
     14 	
     15 	
     16 	$(document).ready(function() {
     17 		
     18 		 Modernizr.addTest('ipad', function () {
     19 			 return !!navigator.userAgent.match(/iPad/i);
     20 		 });
     21 		 
     22 		 Modernizr.addTest('iphone', function () {
     23 			 return !!navigator.userAgent.match(/iPhone/i);
     24 		 });
     25 
     26 		 Modernizr.addTest('ipod', function () {
     27 			 return !!navigator.userAgent.match(/iPod/i);
     28 		 });
     29 
     30 		 Modernizr.addTest('android', function () {
     31 			 return !!navigator.userAgent.match(/android/i);
     32 		 });
     33 
     34 		 Modernizr.addTest('excludedplatforms', function () {
     35 			 return (Modernizr.ipad || Modernizr.ipod || Modernizr.iphone || Modernizr.android);
     36 		 });
     37 		
     38 		if(!Modernizr.excludedplatforms) {
     39 			jQuery.backgroundVideo(jQuery('#bgvid'), {
     40 				"align" : "centerXY",
     41 				"width" : 1280,
     42 				"height" : 720,
     43 				"path" : "https://s3.amazonaws.com/assets-pyc/",
     44 				"filename" : "lamassu_how_to",
     45 				"types" : [ "mp4", "webm" ]
     46 			});
     47 		
     48 			var video = document.getElementById("video_background");
     49 		
     50 			video.addEventListener("ended",function(){
     51 				video.pause();
     52 				$scope.current = 5;
     53 				$scope.$apply();
     54 			},false);
     55 			
     56 			video.addEventListener("timeupdate",function(){
     57 				if(video.currentTime >= intervals[$scope.current]) {
     58 					$scope.current = ($scope.current+1 >= intervals.length) ? 0 : ($scope.current+1);
     59 					$scope.$apply();
     60 				}
     61 			},false);
     62 		
     63 			setTimeout(function(){
     64 				video.muted = true;
     65 				video.play();
     66 			}, 2000);
     67 		} else {
     68 			$scope.current = 5;
     69 			$scope.$apply();
     70 		}
     71 		
     72 	});
     73 }]);