Added support for embedding videos from new video site: vimeo.com
authorAlan J. Pippin <ajp@server.pippins.net>
Fri, 18 Apr 2008 02:37:48 +0000 (20:37 -0600)
committerAlan J. Pippin <ajp@pippins.net>
Fri, 18 Apr 2008 02:37:48 +0000 (20:37 -0600)
ItemAddEmbedVideo.inc
templates/ItemAddEmbedVideo.tpl

index 6bb160fbc5b7ebaff3e94f00b1d1b6e0ece01a08..0e277a490427e598fda49ef8a32c2473ca12118b 100644 (file)
@@ -161,6 +161,9 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
           $myspaceUrlPattern="vids.myspace.com";
           $myspaceUrlPattern2="myspacetv.com";
           $myspaceThumbnailUrl="http://mediaservices.myspace.com/services/rss.ashx?type=video&videoID=";
+
+          /* vimeo */
+          $vimeoUrlPattern="www.vimeo.com";
           
           /* Gallery2 specific paths and variables */
           $urlGenerator =& $gallery->getUrlGenerator();
@@ -781,7 +784,72 @@ class ItemAddEmbedVideo extends ItemAddPlugin {
                 return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__,
                        "Unable to extract embedded video information from url: $url"),NULL,NULL);
               }
-            
+
+          /*
+           **********************************
+           * Embed a Vimeo Video
+           **********************************
+            */
+          } else if(preg_match("/$vimeoUrlPattern/",$url)) {
+
+              /* Make sure we can extract a docID */
+              if(preg_match("/$vimeoUrlPattern\/(.*)/",$url,$matches)) {
+                  $video_id = $matches[1];
+              } else {
+                  return array(GalleryCoreApi::error(ERROR_BAD_PARAMETER,__FILE__,__LINE__,
+                               "Unable to extract video 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('/<meta name="description" content="(.+?)"/i',
+                         $contents, $matches);
+              $summary=$matches[1];
+
+              /* Extract the title from the webpage contents */
+              preg_match('/<meta name="title" content="(.+?)"/i',
+                         $contents, $matches);
+              $title=$matches[1];
+
+              /* Extract the thumbnail URL from the webpage contents */
+              preg_match('/"videothumbnail" href="(.+?)"/i',
+                         $contents, $matches);
+              $thumbnail=$matches[1];
+
+              /* Determine what our width and height should be based on our useRemoteSize parameter */
+              if(!strcmp($useRemoteSize,"true")) {
+                preg_match('/id="vimeo_player_'.$video_id.'".+?style="width:(\d+)px;height:(\d+)px;"/i',
+                           $contents, $matches);
+                $width = $matches[1];
+                $height = $matches[2];
+              }
+
+              /* Determine if the video should autoplay or not based on the autoStart parameter */
+              $autoStartStr="";
+              if(!strcmp($autoStart,"true")) {
+                $autoStartStr="&amp;autoplay=1";
+              }
+
+              /* Format the description to hold a reference to the embedded video */
+              $description = '<object type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'"';
+              $description.= 'data="http://www.vimeo.com/moogaloop.swf?clip_id='.$video_id;
+              $description.= '&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1'.$autoStartStr;
+              $description.= '&amp;show_byline=1&amp;show_portrait=0&amp;color=">';
+              $description.= '<param name="quality" value="best" />';
+              $description.= '<param name="allowfullscreen" value="true" />';
+              $description.= '<param name="scale" value="showAll" />';
+              $description.= '<param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id='.$video_id;
+              $description.= '&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1'.$autoStartStr;
+              $description.= '&amp;show_byline=1&amp;show_portrait=0&amp;color=" />';
+              $description.= '</object>';
+              
           /*
            **********************************
            * Embed a remote .swf file
index 3c29ff4322388f44cf2022af4cdafbd8fd1f03bc..4bb80b3585c623dc2ffadcbeac5a8688b3524a28 100644 (file)
@@ -30,6 +30,7 @@
     <b>Stickam:</b> http://www.stickham.com/editMediaComment.do?method=load&mId=xxxxxxxxx<br>
     <b>Myspace1:</b> http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=xxxxxxxx<br>
     <b>Myspace2:</b> http://myspacetv.com/index.cfm?fuseaction=vids.individual&videoid=xxxxxxxx<br>
+    <b>Vimeo:</b> http://www.vimeo.com/xxxxxx<br>
     <br>
     <b><u>Supported File Types:</u></b><br>
     <b>FlashVideo (.flv):</b> http://aaa.bbb.ccc/video.flv<br>