Newer
Older
/* $Id$ */
/**
* Lightbox video
* @author
* Stella Power, <http://drupal.org/user/66894>
*/
var Lightvideo = {
// startVideo()
startVideo: function (href) {
if (Lightvideo.checkKnownVideos(href)) {
return;
}
else if (href.match(/\.mov$/i)) {
Stella Power
committed
Lightbox.modalHTML ='<object id="qtboxMovie" type="video/quicktime" codebase="http://www.apple.com/qtactivex/qtplugin.cab" data="'+href+'" width="'+Lightbox.modalWidth+'" height="'+Lightbox.modalHeight+'"><param name="allowFullScreen" value="true"></param><param name="src" value="'+href+'" /><param name="scale" value="aspect" /><param name="controller" value="true" /><param name="autoplay" value="true" /><param name="bgcolor" value="#000000" /><param name="enablejavascript" value="true" /></object>';
Stella Power
committed
Lightbox.modalHTML = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+Lightbox.modalWidth+'" height="'+Lightbox.modalHeight+'" id="qtboxMovie"><param name="allowFullScreen" value="true"></param><param name="src" value="'+href+'" /><param name="scale" value="aspect" /><param name="controller" value="true" /><param name="autoplay" value="true" /><param name="bgcolor" value="#000000" /><param name="enablejavascript" value="true" /></object>';
else if (href.match(/\.wmv$/i) || href.match(/\.asx$/i)) {
Lightbox.modalHTML = '<object NAME="Player" WIDTH="'+Lightbox.modalWidth+'" HEIGHT="'+Lightbox.modalHeight+'" align="left" hspace="0" type="application/x-oleobject" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"><param name="allowFullScreen" value="true"></param><param NAME="URL" VALUE="'+href+'"></param><param NAME="AUTOSTART" VALUE="true"></param><param name="showControls" value="true"></param><embed WIDTH="'+Lightbox.modalWidth+'" HEIGHT="'+Lightbox.modalHeight+'" align="left" hspace="0" SRC="'+href+'" TYPE="application/x-oleobject" AUTOSTART="false"></embed></object>';
href = Drupal.settings.basePath + 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 + '"';
flashvars = 'flashvars="' + variables + '"';
Lightbox.modalHTML = '<embed type="application/x-shockwave-flash" ' +
'src="' + href + '" ' +
'id="' + id + '" name="' + id + '" ' + bgcolor + ' ' +
'quality="high" wmode="transparent" ' + flashvars + ' ' +
'height="' + Lightbox.modalHeight + '" ' +
'width="' + Lightbox.modalWidth + '" ' +
Stella Power
committed
'allowfullscreen="true" ' +
},
// 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) {
'youtube.com/v/([^"&]+)',
'youtube.com/watch\\?v=([^"&]+)',
for (var i = 0; i < patterns.length; i++) {
var pattern = new RegExp(patterns[i], "i");
var results = pattern.exec(href);
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) {
'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);
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) {
'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);
Lightbox.videoId = results[1];
Lightvideo.createEmbed("http://www.metacafe.com/fplayer/"+Lightbox.videoId+"/.swf", "flvvideo", "#ffffff");
return true;
}
}
return false;
},
// checkIFilmSpikeVideo()
checkIFilmSpikeVideo: function(href) {
'spike.com/video/[^/&"]*?/(\\d+)',
'ifilm.com/video/[^/&"]*?/(\\d+)',
'ifilm.com/video/([^/&"]*)'
];
for (var i = 0; i < patterns.length; i++) {
var pattern = new RegExp(patterns[i], "i");
var results = pattern.exec(href);
Lightvideo.createEmbed("http://www.spike.com/efp", "flvvideo", "#000", "flvbaseclip="+Lightbox.videoId+"&");
return true;
}
}
return false;
},
// checkMySpaceVideo()
checkMySpaceVideo: function(href) {
'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);
Lightvideo.createEmbed("http://lads.myspace.com/videos/vplayer.swf", "flvvideo", "#ffffff", "m="+Lightbox.videoId);
return true;
}
}
return false;
},
// checkLiveVideo()
checkLiveVideo: function(href) {
'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);