From 11e31584b57655ce9567fa9c69f7936846685a97 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 13 Mar 2012 16:07:43 +0000 Subject: [PATCH] --- inc/commons/class.common.page.php | 7 ++- inc/commons/class.common.tools.php | 89 ++++++++++++++++++------------ js/browserInfos.js | 14 +++++ js/flashdetect.js | 5 ++ js/tube.js | 86 +++++++++++++++++++++++------ 5 files changed, 150 insertions(+), 51 deletions(-) create mode 100644 js/flashdetect.js diff --git a/inc/commons/class.common.page.php b/inc/commons/class.common.page.php index 63371a951..58fd503bf 100644 --- a/inc/commons/class.common.page.php +++ b/inc/commons/class.common.page.php @@ -43,9 +43,13 @@ class commonPage { public static function search($args) { global $core; + if(!isset($args[0])){ + return; + } if (!commonDroits::recherche($args[0])) { return; } + cubePage::emptyfield(); $settings = $core->user->getSettings($args[0]); $action = 'search' . ucfirst($args[0]); @@ -78,8 +82,9 @@ class commonPage { $res = ''; diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 08a9edc8b..f2de47cad 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -44,28 +44,37 @@ class commonTools { } public static function tube($args) { - global $css, $js; + global $css, $js, $jsnomerge, $jsvar; $css = array(); $js[] = JS_PATH . '/tube.js'; + $jsnomerge[] = JS_PATH . '/flashdetect.js'; $js[] = JS_PATH . '/modernizr.js'; $url = $_GET['u']; $hash = sha1($url); - $web = '/tube/' . $hash . '/'; - $dir = ROOT . $web; - if (!file_exists($dir)) { + $onlyplayer = isset($_GET['onlyplayer']) && $onlyplayer; - mkdir($dir, 0777, true); - $ext = files::getExtension($url); - $original = $dir . 'video.' . $ext; - copy($url, $original); + if (!$onlyplayer) { + $web = '/tube/' . $hash . '/'; + $dir = ROOT . $web; + if (!file_exists($dir)) { + mkdir($dir, 0777, true); + $ext = files::getExtension($url); + $original = $dir . 'video.' . $ext; + copy($url, $original); - require_once ROOT . '/inc/ws/Util/class.ws.tools.php'; - wsTools::encodeWebVideos($original); + require_once ROOT . '/inc/ws/Util/class.ws.tools.php'; + wsTools::encodeWebVideos($original); + } + } else { + $e = explode('/', $url); + array_pop($e); + $dir = $web = implode('/', $e); } + $jsvar['priority'] = isset($_GET['html5']) && $_GET['html5'] ? 'html5' : 'flash'; $loop = isset($_GET['loop']) ? $_GET['loop'] : 0; $autoplay = isset($_GET['autoplay']) ? $_GET['autoplay'] : 0; @@ -76,45 +85,51 @@ class commonTools { $fv = array('video' => $url, 'autoPlay' => $autoplay == 1, 'controls' => $controls == 1, - 'loop' => $loop == 1); + 'loop' => $loop == 1, + 'background' => trim($background, '#')); + - if ($displayPoster && file_exists($dir . 'video.jpg')) { - $poster = $web . 'video.jpg'; - $fv['poster'] = 'http://' . $_SERVER['HTTP_HOST'] . $poster; + if (file_exists($dir . 'video.jpg')) { + if ($displayPoster) { + $poster = $web . 'video.jpg'; + $fv['poster'] = $web . $poster; + } + $dim = getimagesize($dir . 'video.jpg'); } $res = ''; - $alt = ''; + $flash = cubeMedia::flashObject('/swf/video.swf', '100%', '100%', $fv, 'videoflash', '', 10, $background, '', 'true', 'noscale', 'opaque'); + $res.=$video; + $res.=$flash; //ob_end_clean(); echo $res; //exit; @@ -126,8 +141,9 @@ class commonTools { global $js; global $jsvar; - $jsnomerge[] = 'http://www.featureblend.com/flash_detect_1-0-4/flash_detect_min.js'; + $jsnomerge[] = JS_PATH . '/flashdetect.js'; $js[] = JS_PATH . '/browserInfos.js'; + $js[] = JS_PATH . '/modernizr.js'; $jsvar['NO_FLASH'] = __("Adobe Flash Player non détecté"); $res = commonPage::barre(); $res .= commonPage::tMain(); @@ -137,6 +153,11 @@ class commonTools { $res.='' . __('Navigateur') . '' . $_SERVER['HTTP_USER_AGENT'] . ''; $res.='' . __('Adresse IP') . '' . $_SERVER['REMOTE_ADDR'] . ''; $res.='' . __('Adobe Flash Player') . ''; + $res.='' . __('Support de la video') . '
'; + $res.='OGV :
'; + $res.='H264 :
'; + $res.='WEBM :
'; + $res.=''; $res.=''; $res .= ''; $res .= commonPage::bf(); diff --git a/js/browserInfos.js b/js/browserInfos.js index d08aaeae7..a218e26c1 100644 --- a/js/browserInfos.js +++ b/js/browserInfos.js @@ -7,4 +7,18 @@ function load_browser_infos(){ $(this).html(FlashDetect.major+"."+FlashDetect.minor+"."+FlashDetect.revision); } }); + + $('.f').each(function(){ + $(this).html(getModernizrValue($(this).attr('data-feature'))); + }); +} + +function getModernizrValue(f){ + eval('var r=Modernizr.'+f); + if(r==true){ + r='true'; + }else if(r==false){ + r='false'; + } + return r; } \ No newline at end of file diff --git a/js/flashdetect.js b/js/flashdetect.js new file mode 100644 index 000000000..ebdff92fd --- /dev/null +++ b/js/flashdetect.js @@ -0,0 +1,5 @@ +//http://www.featureblend.com/license.txt +var FlashDetect=new function(){var self=this;self.installed=false;self.raw="";self.major=-1;self.minor=-1;self.revision=-1;self.revisionStr="";var activeXDetectRules=[{"name":"ShockwaveFlash.ShockwaveFlash.7","version":function(obj){return getActiveXVersion(obj);}},{"name":"ShockwaveFlash.ShockwaveFlash.6","version":function(obj){var version="6,0,21";try{obj.AllowScriptAccess="always";version=getActiveXVersion(obj);}catch(err){} +return version;}},{"name":"ShockwaveFlash.ShockwaveFlash","version":function(obj){return getActiveXVersion(obj);}}];var getActiveXVersion=function(activeXObj){var version=-1;try{version=activeXObj.GetVariable("$version");}catch(err){} +return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new ActiveXObject(name);}catch(err){obj={activeXError:true};} +return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray[0].split(" ")[1],10),"minor":parseInt(versionArray[1],10),"revision":parseInt(versionArray[2],10),"revisionStr":versionArray[2]};};var parseStandardVersion=function(str){var descParts=str.split(/ +/);var majorMinor=descParts[2].split(/\./);var revisionStr=descParts[3];return{"raw":str,"major":parseInt(majorMinor[0],10),"minor":parseInt(majorMinor[1],10),"revisionStr":revisionStr,"revision":parseRevisionStrToInt(revisionStr)};};var parseRevisionStrToInt=function(str){return parseInt(str.replace(/[a-zA-Z]/g,""),10)||self.revision;};self.majorAtLeast=function(version){return self.major>=version;};self.minorAtLeast=function(version){return self.minor>=version;};self.revisionAtLeast=function(version){return self.revision>=version;};self.versionAtLeast=function(major){var properties=[self.major,self.minor,self.revision];var len=Math.min(properties.length,arguments.length);for(i=0;i=arguments[i]){if(i+10){var type='application/x-shockwave-flash';var mimeTypes=navigator.mimeTypes;if(mimeTypes&&mimeTypes[type]&&mimeTypes[type].enabledPlugin&&mimeTypes[type].enabledPlugin.description){var version=mimeTypes[type].enabledPlugin.description;var versionObj=parseStandardVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revisionStr=versionObj.revisionStr;self.revision=versionObj.revision;self.installed=true;}}else if(navigator.appVersion.indexOf("Mac")==-1&&window.execScript){var version=-1;for(var i=0;i=10; + + + if(priority=='html5'){ + if(html5support){ + initHTML5Video(); + }else{ + initFlashVideo(); } - }); + }else{ + if(flashsupport){ + initFlashVideo(); + }else{ + initHTML5Video(); + } + } $(window).resize(resizeTube); resizeTube(); } + +function initHTML5Video(){ + + var template=$("#videohtml").attr('data-src'); + if($("#videohtml").attr('src')==undefined){ + if(Modernizr.video.ogg){ + $("#videohtml").attr('src',template+'video.ogv'); + }else if(Modernizr.video.webm){ + $("#videohtml").attr('src',template+'video.webm'); + }else if(Modernizr.video.h264){ + $("#videohtml").attr('src',template+'video.mp4'); + } + } + $("#videohtml").show(); + + $(document).one('click','video',function(){ + $('video').each(function(){ + this.play(); + }); + return true; + }) +} + +function initFlashVideo(){ + $("#videoflash").css('display','block'); +} + +function tubeHideControls(video){ + + $(video).removeAttr('controls'); +} + function resizeTube(){ - $('video').css('width',$(window).width()); - $('video').css('height',$(window).height()); + $('video').each(function(){ + var vw=parseInt($(this).attr('data-width')); + var vh=parseInt($(this).attr('data-height')); + var ww=$(window).width(); + var hh=$(window).height(); + var s=Math.min(ww/vw,hh/vh); + var w=vw*s; + var h=vh*s; - $('video').attr('width',$(window).width()); - $('video').attr('height',$(window).height()); - + $('video').css({ + width:w, + height:h, + left:(ww-w)/2, + top:(hh-h)/2, + position:'absolute' + }); + + $('video').each(function(){ + if($(this).attr('src')!=undefined){ + $("video").show(); + } + }) + }); } \ No newline at end of file -- 2.39.5