}
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;
$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 = '<style type="text/css">';
$res.='html, body {margin: 0;padding: 0;height: 100%;color:#fff;overflow:hidden;}';
$res.='body,video{background:' . $background . ';}';
- $res.='video{width:100%;height:100%;}';
- $res.='#header{display:none;}';
+ $res.='video{width:100%;height:100%;display:none;}';
+ $res.='#header,#videoflash,#videohtml{display:none;}';
$res.='</style>';
- $alt = '<video width="100%" height="100%" data-src="' . $web . '"';
- if ($controls) {
- $alt.=' controls="controls"';
+ $video = '<video id="videohtml" width="100%" height="100%" data-src="' . $web . '"';
+ if (isset($dim)) {
+ $video.=' data-width="' . $dim[0] . '" data-height="' . $dim[1] . '"';
+ }
+
+ $ios = stristr($_SERVER['HTTP_USER_AGENT'], 'ipad') || stristr($_SERVER['HTTP_USER_AGENT'], 'iphone') || stristr($_SERVER['HTTP_USER_AGENT'], 'ipod');
+ $video.=' controls="controls"';
+ if (!$controls) {
+ $video.=' onplay="tubeHideControls(this);"';
}
if ($loop) {
- $alt.=' onended="this.play();"';
- //$alt.=' loop="loop"';
+ $video.=' onended="this.play();"';
}
if ($autoplay) {
- $alt.=' autoplay="autoplay"';
+ $video.=' data-autoplay="autoplay"';
}
- if ($displayPoster && isset($poster)) {
- $alt.=' poster="' . $web . 'video.jpg"';
- }
- $alt .= '>';
- $alt .= '</video>';
-
-
- if (isset($_GET['html5']) && $_GET['html5']) {
- $res.='<div id="video">' . $alt . '</div>';
- } else {
- $res .= cubeMedia::flash2('/swf/video.swf', '100%', '100%', $fv, 'video', '', 10, '#000000', $alt, true);
+ if (($displayPoster || $ios) && isset($poster)) {
+ $video.=' poster="' . $web . 'video.jpg"';
}
+ $video .= '>';
+ $video .= '</video>';
+ $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;
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();
$res.='<tr><td>' . __('Navigateur') . '</td><td>' . $_SERVER['HTTP_USER_AGENT'] . '</td></tr>';
$res.='<tr><td>' . __('Adresse IP') . '</td><td>' . $_SERVER['REMOTE_ADDR'] . '</td></tr>';
$res.='<tr><td>' . __('Adobe Flash Player') . '</td><td class="flashversion"></td></tr>';
+ $res.='<tr><td>' . __('Support de la video') . '</td><td><strong class="f" data-feature="video"></strong><br />';
+ $res.='OGV : <span class="f" data-feature="video.ogg"></span><br />';
+ $res.='H264 : <span class="f" data-feature="video.h264"></span><br />';
+ $res.='WEBM : <span class="f" data-feature="video.webm"></span><br />';
+ $res.='</td></tr>';
$res.='</table>';
$res .= '</div>';
$res .= commonPage::bf();
--- /dev/null
+//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<len;i++){if(properties[i]>=arguments[i]){if(i+1<len&&properties[i]==arguments[i]){continue;}else{return true;}}else{return false;}}};self.FlashDetect=function(){if(navigator.plugins&&navigator.plugins.length>0){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<activeXDetectRules.length&&version==-1;i++){var obj=getActiveXObject(activeXDetectRules[i].name);if(!obj.activeXError){self.installed=true;version=activeXDetectRules[i].version(obj);if(version!=-1){var versionObj=parseActiveXVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revision=versionObj.revision;self.revisionStr=versionObj.revisionStr;}}}}}();};FlashDetect.JS_RELEASE="1.0.4";
\ No newline at end of file
TO_LOAD[TO_LOAD.length]='load_tube();';
function load_tube(){
- $('video').each(function(){
- var template=$(this).attr('data-src');
- if($(this).attr('src')==undefined){
- if(Modernizr.video.ogg){
- $(this).attr('src',template+'video.ogv');
- }else if(Modernizr.video.webm){
- $(this).attr('src',template+'video.webm');
- }else if(Modernizr.video.h264){
- $(this).attr('src',template+'video.mp4');
- }
+ var html5support=(Modernizr.video && (Modernizr.video.ogg || Modernizr.video.webm || Modernizr.video.h264))!=false;
+ var flashsupport=FlashDetect.installed && FlashDetect.major>=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