/* $Id: lightbox_video.js,v 1.1.4.20 2010/09/21 17:57:22 snpower Exp $ */ /** * Lightbox video * @author * Stella Power, */ var Lightvideo; // start jQuery block (function ($) { Lightvideo = { // startVideo() startVideo: function (href) { if (Lightvideo.checkKnownVideos(href)) { return; } else if (href.match(/\.mov$/i)) { if (navigator.plugins && navigator.plugins.length) { Lightbox.modalHTML =''; } else { Lightbox.modalHTML = ''; } } else if (href.match(/\.wmv$/i) || href.match(/\.asx$/i)) { Lightbox.modalHTML = ''; } else { Lightbox.videoId = href; variables = ''; if (!href.match(/\.swf$/i)) { href = Lightbox.flvPlayer + '?file=' + href; if (Lightbox.flvFlashvars.length) { variables = Lightbox.flvFlashvars; } } Lightvideo.createEmbed(href, "flvplayer", "#ffffff", variables); } }, // createEmbed() createEmbed: function(href, id, color, variables) { var bgcolor = 'bgcolor="' + color + '"'; var flashvars = ''; if (variables) { flashvars = 'flashvars="' + variables + '"'; } Lightbox.modalHTML = ''; }, // checkKnownVideos() checkKnownVideos: function(href) { if (Lightvideo.checkYouTubeVideo(href) || Lightvideo.checkGoogleVideo(href) || Lightvideo.checkMySpaceVideo(href) || Lightvideo.checkLiveVideo(href) || Lightvideo.checkMetacafeVideo(href) || Lightvideo.checkIFilmSpikeVideo(href) ) { return true; } return false; }, // checkYouTubeVideo() checkYouTubeVideo: function(href) { var patterns = [ 'youtube.com/v/([^"&]+)', 'youtube.com/watch\\?v=([^"&]+)', 'youtube.com/\\?v=([^"&]+)' ]; for (var i = 0; i < patterns.length; i++) { var pattern = new RegExp(patterns[i], "i"); var results = pattern.exec(href); if (results !== null) { Lightbox.videoId = results[1]; var href = "http://www.youtube.com/v/"+Lightbox.videoId; var variables = 'fs=1'; if (Lightbox.flvFlashvars.length) { variables = variables + '&' + Lightbox.flvFlashvars; href = href + '&' + variables; } Lightvideo.createEmbed(href, "flvvideo", "#ffffff", variables); return true; } } return false; }, // checkGoogleVideo() checkGoogleVideo: function(href) { var patterns = [ 'http://video.google.[a-z]{2,4}/googleplayer.swf\\?docId=(-?\\d*)', 'http://video.google.[a-z]{2,4}/videoplay\\?docid=([^&]*)&', 'http://video.google.[a-z]{2,4}/videoplay\\?docid=(.*)' ]; for (var i = 0; i < patterns.length; i++) { var pattern = new RegExp(patterns[i], "i"); var results = pattern.exec(href); if (results !== null) { Lightbox.videoId = results[1]; var href = "http://video.google.com/googleplayer.swf?docId="+Lightbox.videoId+"&hl=en"; var variables = 'fs=true'; if (Lightbox.flvFlashvars.length) { variables = variables + '&' + Lightbox.flvFlashvars; href = href + '&' + variables; } Lightvideo.createEmbed(href, "flvvideo", "#ffffff", variables); return true; } } return false; }, // checkMetacafeVideo() checkMetacafeVideo: function(href) { var patterns = [ 'metacafe.com/watch/(\.[^/]*)/(\.[^/]*)/', 'metacafe.com/watch/(\.[^/]*)/(\.*)', 'metacafe.com/fplayer/(\.[^/]*)/(\.[^.]*).' ]; for (var i = 0; i < patterns.length; i++) { var pattern = new RegExp(patterns[i], "i"); var results = pattern.exec(href); if (results !== null) { Lightbox.videoId = results[1]; Lightvideo.createEmbed("http://www.metacafe.com/fplayer/"+Lightbox.videoId+"/.swf", "flvvideo", "#ffffff"); return true; } } return false; }, // checkIFilmSpikeVideo() checkIFilmSpikeVideo: function(href) { var patterns = [ 'spike.com/video/[^/&"]*?/(\\d+)', 'ifilm.com/video/[^/&"]*?/(\\d+)', 'spike.com/video/([^/&"]*)', 'ifilm.com/video/([^/&"]*)' ]; for (var i = 0; i < patterns.length; i++) { var pattern = new RegExp(patterns[i], "i"); var results = pattern.exec(href); if (results !== null) { Lightbox.videoId = results[1]; Lightvideo.createEmbed("http://www.spike.com/efp", "flvvideo", "#000", "flvbaseclip="+Lightbox.videoId+"&"); return true; } } return false; }, // checkMySpaceVideo() checkMySpaceVideo: function(href) { var patterns = [ 'src="myspace.com/index.cfm\\?fuseaction=vids.individual&videoid=([^&"]+)', 'myspace.com/index.cfm\\?fuseaction=vids.individual&videoid=([^&"]+)', 'src="myspacetv.com/index.cfm\\?fuseaction=vids.individual&videoid=([^&"]+)"', 'myspacetv.com/index.cfm\\?fuseaction=vids.individual&videoid=([^&"]+)' ]; for (var i = 0; i < patterns.length; i++) { var pattern = new RegExp(patterns[i], "i"); var results = pattern.exec(href); if (results !== null) { Lightbox.videoId = results[1]; Lightvideo.createEmbed("http://lads.myspace.com/videos/vplayer.swf", "flvvideo", "#ffffff", "m="+Lightbox.videoId); return true; } } return false; }, // checkLiveVideo() checkLiveVideo: function(href) { var patterns = [ 'livevideo.com/flvplayer/embed/([^"]*)"', 'livevideo.com/video/[^/]*?/([^/]*)/', 'livevideo.com/video/([^/]*)/' ]; for (var i = 0; i < patterns.length; i++) { var pattern = new RegExp(patterns[i], "i"); var results = pattern.exec(href); if (results !== null) { Lightbox.videoId = results[1]; Lightvideo.createEmbed("http://www.livevideo.com/flvplayer/embed/"+Lightbox.videoId, "flvvideo", "#ffffff"); return true; } } return false; } }; //End jQuery block }(jQuery));