From: Alan Jack Pippin Date: Fri, 29 Jun 2007 05:49:09 +0000 (-0600) Subject: Added new autoStart parameter. Added new useRemoteSize parameter. X-Git-Tag: 1_0_4~5 X-Git-Url: http://git.pippins.net/embedvideo/.git/static/images/%7Blink_attendance%7D?a=commitdiff_plain;h=b1952ee04d2ae62ede96d5c61ab096cd237c1c3b;p=embedvideo%2F.git Added new autoStart parameter. Added new useRemoteSize parameter. --- diff --git a/ItemAddEmbedVideo.inc b/ItemAddEmbedVideo.inc index e5eecd1..28d4a80 100644 --- a/ItemAddEmbedVideo.inc +++ b/ItemAddEmbedVideo.inc @@ -66,27 +66,37 @@ class ItemAddEmbedVideo extends ItemAddPlugin { /* Store any Parameters into some simpler, shorter, local variables */ global $debugOutput, $useInternalFlvPlayer, $youtubeDevId; global $width, $height, $externalFlvPlayer, $externalFlvPlayerVars; - global $flvThumbnail; - - $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'); + global $flvThumbnail, $useRemoteSize, $autoStart; + /* 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"); + /* Store other string constants we'll use later */ /* youtube */ $youtubeUrlPattern="youtube.com"; $youtubeApiUrl="http://www.youtube.com/api2_rest"; + $youtubeWidth="425"; + $youtubeHeight="350"; /* google */ $googleUrlPattern="video.google.com"; $googlePlayer="http://video.google.com/googleplayer.swf"; - + $googleWidth="400"; + $googleHeight="326"; + /* yahoo */ $yahooUrlPattern="video.yahoo.com"; $yahooThumbnailUrl="http://thmg01.video.search.yahoo.com/image/"; @@ -138,7 +148,6 @@ class ItemAddEmbedVideo extends ItemAddPlugin { "Unable to get video information at url: $url - $response"),null,null); } - if(!strcmp($debugOutput,"true")) { print "$xml"; } @@ -163,12 +172,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.= ''; $description.= ''; - $description.= ''; $description.= "
$summary"; @@ -215,11 +236,23 @@ 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.= 'src="'.$googlePlayer.'?docId='.$doc_id.$autoStartStr.'"> '; $description.= ''; $description.= "
$summary"; @@ -227,6 +260,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin { ********************************** * Embed a Yahoo Video ********************************** + * TODO: The autoStart parameter doesn't work with the yahoo video player */ } else if(preg_match("/$yahooUrlPattern/",$url)) { @@ -264,8 +298,10 @@ class ItemAddEmbedVideo extends ItemAddPlugin { /* Format the description to hold a reference to the embedded video */ preg_match('/()/', $contents, $matches); $description=$matches[1]; - $description=preg_replace("/width='\d+'/","width='".$width."'",$description); - $description=preg_replace("/height='\d+'/","height='".$height."'",$description); + if(!strcmp($useRemoteSize,"false")) { + $description=preg_replace("/width='\d+'/","width='".$width."'",$description); + $description=preg_replace("/height='\d+'/","height='".$height."'",$description); + } $description.= "
$summary"; /* @@ -306,8 +342,13 @@ class ItemAddEmbedVideo extends ItemAddPlugin { preg_match('/(embed src.+?\/embed)/', $contents, $matches); $description="<".$matches[1]; $description=preg_replace("/"/","'",$description); - $description=preg_replace("/width='\d+'/","width='".$width."'",$description); - $description=preg_replace("/height='\d+'/","height='".$height."'",$description); + if(!strcmp($useRemoteSize,"false")) { + $description=preg_replace("/width='\d+'/","width='".$width."'",$description); + $description=preg_replace("/height='\d+'/","height='".$height."'",$description); + } + if(!strcmp($autoStart,"true")) { + $description=preg_replace("/\.swf/",".swf?playerVars=autoPlay=yes",$description); + } $description.= ""; $description.= "
$summary"; @@ -372,7 +413,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 { @@ -401,7 +442,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin { $description.= ''; $description.= ''; $description.= ''; $description.= ''; @@ -411,7 +452,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin { $description.= '"; */ return($params['override'][$name]); - } else { + } else if(isset($params['default'][$name])) { + /* print "default $name = ".$params['default'][$name] ."
"; */ return($params['default'][$name]); + } else { + /* print "$name = $default
"; */ + return($default); } } /** * A simple function to get the headers only (no body) for a given URL - * + * This was taken from GalleryCoreApi::requestWebPage */ function fetchWebFileHeaders($url, $requestHeaders=array()) { global $gallery; diff --git a/module.inc b/module.inc index 8a9f40d..eb03f50 100644 --- a/module.inc +++ b/module.inc @@ -77,7 +77,7 @@ class EmbedVideoModule extends GalleryModule { if (!isset($params['embedvideodefaultVariables'])) { $ret = $this->setParameter('embedvideodefaultVariables', - 'height=240|width=320|useInternalFlvPlayer=true'); + 'height=240|width=320|useInternalFlvPlayer=true|useRemoteSize=false'); if ($ret) { return $ret; } diff --git a/templates/EmbedVideoSiteAdmin.tpl b/templates/EmbedVideoSiteAdmin.tpl index 6a7c967..a0609cd 100644 --- a/templates/EmbedVideoSiteAdmin.tpl +++ b/templates/EmbedVideoSiteAdmin.tpl @@ -124,6 +124,12 @@ youtubeDevIdxxxxxxxxxxx {g->text text="specify the youtube Developer ID used when this plugin makes API calls to youtube"} + useRemoteSizetrue/false + {g->text text="use the remote video size instead of the width and height specified here"} + + autoStarttrue/false + {g->text text="specify if the embedded video players should autostart the videos or not"} + width320 {g->text text="specify the width dimension of the embedded video player"}