X-Git-Url: http://git.pippins.net/embedvideo/.git/%27%20%20%20%20.%20%24GLOBALS%5B%27phpgw%27%5D-%3Elink%28%27inc/jquery/jquery.tablesorter.css%27%29.%27?a=blobdiff_plain;f=ItemAddEmbedVideo.inc;h=983ec79d041f82e00dcbb2c4968928f06d7ade98;hb=26f4eaa28c1a947b5e1f8f58f1cd653596e2253d;hp=b8941f60e09fcc5409f20bec9ea527629f35eea1;hpb=2cffc34190c8edafe96dc51859ca3ca13e70ccde;p=embedvideo%2F.git
diff --git a/ItemAddEmbedVideo.inc b/ItemAddEmbedVideo.inc
index b8941f6..983ec79 100644
--- a/ItemAddEmbedVideo.inc
+++ b/ItemAddEmbedVideo.inc
@@ -18,6 +18,9 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
+GalleryCoreApi::requireOnce('modules/gd/classes/GdToolkitHelper.class');
+
+
/**
* This plugin will handle the addition of embedded video objects
* @package embedVideo
@@ -66,22 +69,63 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
/* Store any Parameters into some simpler, shorter, local variables */
global $debugOutput, $useInternalFlvPlayer, $youtubeDevId;
global $width, $height, $externalFlvPlayer, $externalFlvPlayerVars;
- global $flvThumbnail;
+ global $flvThumbnail, $useRemoteSize, $autoStart;
- $debugOutput = $this->getParameter($ItemAddEmbedVideo, 'debugOutput');
- $useInternalFlvPlayer = $this->getParameter($ItemAddEmbedVideo, 'useInternalFlvPlayer');
- $youtubeDevId = $this->getParameter($ItemAddEmbedVideo, 'youtubeDevId');
- $width = $this->getParameter($ItemAddEmbedVideo, 'width');
- $height = $this->getParameter($ItemAddEmbedVideo, 'height');
- $externalFlvPlayer = $this->getParameter($ItemAddEmbedVideo, 'externalFlvPlayer');
- $externalFlvPlayerVars = $this->getParameter($ItemAddEmbedVideo, 'externalFlvPlayerVars');
- $flvThumbnail = $this->getParameter($ItemAddEmbedVideo, 'flvThumbnail');
+ /* Find out what value our parameters should have by looking to see if they
+ * are defined in our overrides section or default section. If they are not
+ * defined in either of these 2 places, pass in a default value to set them to
+ */
+ $debugOutput = $this->getParameter($ItemAddEmbedVideo, 'debugOutput', "false");
+ $useInternalFlvPlayer = $this->getParameter($ItemAddEmbedVideo, 'useInternalFlvPlayer', "true");
+ $youtubeDevId = $this->getParameter($ItemAddEmbedVideo, 'youtubeDevId', "");
+ $width = $this->getParameter($ItemAddEmbedVideo, 'width', "320");
+ $height = $this->getParameter($ItemAddEmbedVideo, 'height', "240");
+ $externalFlvPlayer = $this->getParameter($ItemAddEmbedVideo, 'externalFlvPlayer', "");
+ $externalFlvPlayerVars = $this->getParameter($ItemAddEmbedVideo, 'externalFlvPlayerVars', "");
+ $flvThumbnail = $this->getParameter($ItemAddEmbedVideo, 'flvThumbnail', "");
+ $useRemoteSize = $this->getParameter($ItemAddEmbedVideo, 'useRemoteSize', "false");
+ $autoStart = $this->getParameter($ItemAddEmbedVideo, 'autoStart', "false");
+
+ /* Print our stored/set Parameters */
+ if(!strcmp($debugOutput,"true")) {
+ print "
";
+ print "
Variable Parameters
";
+ print "debugOutput=$debugOutput ";
+ print "useInternalFlvPlayer=$useInternalFlvPlayer ";
+ print "youtubeDevId=$youtubeDevId ";
+ print "width=$width ";
+ print "height=$height ";
+ print "externalFlvPlayer=$externalFlvPlayer ";
+ print "externalFlvPlayerVars=$externalFlvPlayerVars ";
+ print "flvThumbnail=$flvThumbnail ";
+ print "useRemoteSize=$useRemoteSize ";
+ print "autoStart=$autoStart ";
+ print "";
+ }
/* Store other string constants we'll use later */
+
+ /* youtube */
$youtubeUrlPattern="youtube.com";
$youtubeApiUrl="http://www.youtube.com/api2_rest";
+ /* We can't extract the server size from youtube */
+ $youtubeWidth="425";
+ $youtubeHeight="350";
+
+ /* google */
$googleUrlPattern="video.google.com";
$googlePlayer="http://video.google.com/googleplayer.swf";
+ /* We can't extract the server size from google video */
+ $googleWidth="400";
+ $googleHeight="326";
+
+ /* yahoo */
+ $yahooUrlPattern="video.yahoo.com";
+ $yahooThumbnailUrl="http://thmg01.video.search.yahoo.com/image/";
+
+ /* metacafe */
+ $metacafeUrlPattern="metacafe.com";
+ $metacafeThumbnailUrl="http://www.metacafe.com/thumb/";
/* Gallery2 specific paths and variables */
$urlGenerator =& $gallery->getUrlGenerator();
@@ -126,9 +170,10 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
"Unable to get video information at url: $url - $response"),null,null);
}
-
if(!strcmp($debugOutput,"true")) {
+ print "
Youtube XML Dump
";
print "$xml";
+ print "";
}
/* Extract certain information from the xml feed */
@@ -151,12 +196,24 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
$summary = $description[0][0];
$thumbnail = $thumbnail[0][0];
+ /* Determine what our width and height should be based on our useRemoteSize parameter */
+ if(!strcmp($useRemoteSize,"true")) {
+ $width = $youtubeWidth;
+ $height = $youtubeHeight;
+ }
+
+ /* Determine if the video should autoplay or not based on the autoStart parameter */
+ $autoStartStr="";
+ if(!strcmp($autoStart,"true")) {
+ $autoStartStr="&autoplay=1";
+ }
+
/* Format the description to hold a reference to the embedded video */
$description = '';
$description.= " $summary";
@@ -203,13 +260,121 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
$thumbnail=$matches[1];
$thumbnail=preg_replace("/offsetms=0/","offsetms=0",$thumbnail);
+ /* Determine what our width and height should be based on our useRemoteSize parameter */
+ if(!strcmp($useRemoteSize,"true")) {
+ $width = $googleWidth;
+ $height = $googleHeight;
+ }
+
+ /* Determine if the video should autoplay or not based on the autoStart parameter */
+ $autoStartStr="";
+ if(!strcmp($autoStart,"true")) {
+ $autoStartStr="&autoplay=1";
+ }
+
/* Format the description to hold a reference to the embedded video */
- $description = '';
$description.= " $summary";
+
+ /*
+ **********************************
+ * Embed a Yahoo Video
+ **********************************
+ * TODO: The autoStart parameter doesn't work with the yahoo video player
+ */
+ } else if(preg_match("/$yahooUrlPattern/",$url)) {
+
+ /* Make sure we can extract a vidID */
+ if(preg_match("/vid=(.*)/",$url,$matches)) {
+ $vid_id = $matches[1];
+ } else {
+ return array(GalleryCoreApi::error(ERROR_BAD_PARAMETER,__FILE__,__LINE__,
+ "Unable to extract vid id from url: $url"),null,null);
+ }
+
+ /* Grab the contents of the webpage used to display the video on video.google.com */
+ list ($successfullyCopied, $contents, $response, $headers) =
+ GalleryCoreApi::fetchWebPage($url, $extraHeaders);
+ if (!$successfullyCopied) {
+ return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__,
+ "Unable to get video information at url: $url - $response"),NULL,NULL);
+ }
+
+ /* Extract the summary from the webpage contents */
+ preg_match('/Description:<\/em>
(.+?)<\/p>/', $contents, $matches);
+ $summary=$matches[1];
+
+ /* Extract the title from the webpage contents */
+ $title="Unknown";
+ if(preg_match('/
(.+?)\s+- Yahoo! Video<\/title>/i', $contents, $matches)) {
+ $title=$matches[1];
+ } else if(preg_match('/(.+?)<\/title>/i', $contents, $matches)) {
+ $title=$matches[1];
+ }
+
+ /* Build the thumbnail URL from the vid_id */
+ $thumbnail=$yahooThumbnailUrl.$vid_id."_01";
+
+ /* Format the description to hold a reference to the embedded video */
+ preg_match('/(";
+ $description.= " $summary";
/*
**********************************
@@ -272,7 +437,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
if(!preg_match("/\w+/",$externalFlvPlayerVars)) {
/* Format the flashvars for the internal G2 flv player */
- $description.= '&showdigits=true&autostart=false&showfsbutton=true&';
+ $description.= '&showdigits=true&autostart='.$autoStart.'&showfsbutton=true&';
$description.= '&repeat=false&lightcolor=0x9999FF';
$description.= '&backcolor=0x888888&frontcolor=0x000000"';
} else {
@@ -301,7 +466,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
$description.= '';
$description.= '';
$description.= '';
$description.= '';
@@ -311,7 +476,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
$description.= '