From: Alan J. Pippin <ajp@server.pippins.net> Date: Fri, 18 Apr 2008 02:37:48 +0000 (-0600) Subject: Added support for embedding videos from new video site: vimeo.com X-Git-Tag: 1_1_1~6 X-Git-Url: http://git.pippins.net/%7Bupdate_day%7D?a=commitdiff_plain;h=8a4f854fa696366b1708d46faa24995e6895004f;p=embedvideo%2F.git Added support for embedding videos from new video site: vimeo.com --- diff --git a/ItemAddEmbedVideo.inc b/ItemAddEmbedVideo.inc index 6bb160f..0e277a4 100644 --- a/ItemAddEmbedVideo.inc +++ b/ItemAddEmbedVideo.inc @@ -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="&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.= '&server=www.vimeo.com&fullscreen=1&show_title=1'.$autoStartStr; + $description.= '&show_byline=1&show_portrait=0&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.= '&server=www.vimeo.com&fullscreen=1&show_title=1'.$autoStartStr; + $description.= '&show_byline=1&show_portrait=0&color=" />'; + $description.= '</object>'; + /* ********************************** * Embed a remote .swf file diff --git a/templates/ItemAddEmbedVideo.tpl b/templates/ItemAddEmbedVideo.tpl index 3c29ff4..4bb80b3 100644 --- a/templates/ItemAddEmbedVideo.tpl +++ b/templates/ItemAddEmbedVideo.tpl @@ -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>