0byt3m1n1
Path:
/
data
/
applications
/
aps
/
gallery
/
2.2-08
/
htdocs
/
modules
/
flashvideo
/
classes
/
[
Home
]
File: FlashVideoRenderer.class
<?php /* * Gallery - a web based photo album viewer and editor * Copyright (C) 2000-2007 Bharat Mediratta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ GalleryCoreApi::requireOnce('modules/core/classes/GalleryRenderer.class'); /** * A renderer for Flash Video. * @package FlashVideo * @subpackage Classes * @author Alan Harder <alan.harder@sun.com> * @version $Revision: 15953 $ */ class FlashVideoRenderer extends GalleryRenderer { /** * @see GalleryRenderer::canBeViewedInline */ function canBeViewedInline($item) { return GalleryUtilities::isA($item, 'GalleryMovieItem') && $item->getMimeType() == 'video/x-flv' && $item->getWidth() > 0 && $item->getHeight() > 0; } /** * @see GalleryRenderer::render */ function render($format, $entity, $item, $params) { global $gallery; $fallback = trim(preg_replace("/[\r\n]/", '', $params['fallback'])); if ($format != 'HTML' || $entity->getMimeType() != 'video/x-flv') { return null; } $urlGenerator =& $gallery->getUrlGenerator(); $src = $urlGenerator->generateUrl( array('view' => 'core.DownloadItem', 'itemId' => $entity->getId(), 'serialNumber' => $entity->getSerialNumber()), array('forceFullUrl' => true, 'forceSessionId' => true, 'htmlEntities' => false)); list ($width, $height, $title) = array($entity->getWidth(), $entity->getHeight(), $item->getTitle()); GalleryCoreApi::requireOnce('lib/smarty_plugins/modifier.markup.php'); $title = smarty_modifier_markup($title, 'strip'); /* Default player: G2flv.swf */ $playerUrl = $urlGenerator->generateUrl( array('href' => 'modules/flashvideo/lib/G2flv.swf'), array('forceFullUrl' => true)); $flashVars = 'flvUrl=' . urlencode($src) . '&Width=' . $width . '&Height=' . $height . '&title=' . urlencode($title); $extraAttr = ''; /* Set allowDL=false to omit download button in upper right of player */ $flashVars .= '&allowDl=true'; $itemId = $item->getId(); list ($ret, $thumbnail) = GalleryCoreApi::fetchThumbnailsByItemIds(array($itemId)); if (!$ret && !empty($thumbnail)) { $thumbUrl = $urlGenerator->generateUrl( array('view' => 'core.DownloadItem', 'itemId' => $thumbnail[$itemId]->getId(), 'serialNumber' => $thumbnail[$itemId]->getSerialNumber()), array('forceFullUrl' => true, 'forceSessionId' => true, 'htmlEntities' => false)); $flashVars .= '&thumbUrl=' . urlencode($thumbUrl); } list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'flashvideo'); if ($ret) { return null; } foreach (array('langDownload' => $module->translate('Download'), 'langLarge' => $module->translate('Large'), 'langNormal' => $module->translate('Normal'), ) as $key => $value) { $flashVars .= '&' . $key . '=' . urlencode($value); } /* * To use FlowPlayer ( http://flowplayer.sourceforge.net ) * place FlowPlayer.swf in the flashvideo/lib directory and uncomment the lines below: */ /* $playerUrl = $urlGenerator->generateUrl( array('href' => 'modules/flashvideo/lib/FlowPlayer.swf'), array('forceFullUrl' => true)); $flashVars = sprintf('baseURL=%s&videoFile=%s%%26x=&autoPlay=true&loop=false', urlencode(dirname($src)), urlencode(basename($src))); $extraAttr = ' wmode="transparent"'; */ /* * To use FLVPlayer ( http://www.peldi.com/fmswiki/index.php?title=FLVPlayer ) * get this version of the player: http://gallery.menalto.com/files/flvplayer.zip * unzip in the flashvideo/lib directory and uncomment the lines below: */ /* $playerUrl = $urlGenerator->generateUrl( array('href' => 'modules/flashvideo/lib/flvplayer.swf'), array('forceFullUrl' => true)); $skinUrl = $urlGenerator->generateUrl( array('href' => 'modules/flashvideo/lib/skin'), array('forceFullUrl' => true)); $flashVars = sprintf('streamName=%s&skinName=%s&autoPlay=true&autoRewind=false', urlencode($src), urlencode($skinUrl)); */ return sprintf( '<script type="text/javascript"> // <![CDATA[ function divResize(id, nw, nh) { var obj = document.getElementById(id); obj.style.width = nw + "px"; obj.style.height = nh + "px"; } // ]]> </script> <div id="flashvideo" style="align:left;width:525px;height:292px"> <object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%%" height="100%%" id="%s"%s%s> <param name="movie" value="%s"/> <param name="FlashVars" value="%s"/> <param name="quality" value="high"/> <param name="scale" value="noscale"/> <param name="salign" value="lt"/> <param name="wmode" value="transparent"/> <param name="allowScriptAccess" value="always"/> <embed src="%s" flashvars="%s" type="application/x-shockwave-flash" width="100%%" height="100%%" quality="high" scale="noscale" salign="lt" wmode="transparent" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"/> <noembed>%s</noembed> </object></div>', !empty($params['id']) ? $params['id'] : 'movie', !empty($params['class']) ? ' class="' . $params['class'] . '"' : '', $extraAttr, $playerUrl, $flashVars, $playerUrl, $flashVars, $fallback); } } ?>