@ -1,7 +0,0 @@ |
||||
<html><head> |
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
||||
</head> |
||||
<body> |
||||
|
||||
</body></html> |
||||
|
||||
@ -0,0 +1,5 @@ |
||||
{ |
||||
"require": { |
||||
"php-ffmpeg/php-ffmpeg": "0.3.x-dev@dev" |
||||
} |
||||
} |
||||
|
After Width: | Height: | Size: 166 B |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
@ -0,0 +1,173 @@ |
||||
/*! |
||||
* MediaElement.js |
||||
* HTML5 <video> and <audio> shim and player |
||||
* http://mediaelementjs.com/
|
||||
* |
||||
* Creates a JavaScript object that mimics HTML5 MediaElement API |
||||
* for browsers that don't understand HTML5 or can't play the provided codec |
||||
* Can play MP4 (H.264), Ogg, WebM, FLV, WMV, WMA, ACC, and MP3 |
||||
* |
||||
* Copyright 2010-2013, John Dyer (http://j.hn)
|
||||
* License: MIT |
||||
* |
||||
*/var mejs=mejs||{};mejs.version="2.13.0";mejs.meIndex=0; |
||||
mejs.plugins={silverlight:[{version:[3,0],types:["video/mp4","video/m4v","video/mov","video/wmv","audio/wma","audio/m4a","audio/mp3","audio/wav","audio/mpeg"]}],flash:[{version:[9,0,124],types:["video/mp4","video/m4v","video/mov","video/flv","video/rtmp","video/x-flv","audio/flv","audio/x-flv","audio/mp3","audio/m4a","audio/mpeg","video/youtube","video/x-youtube"]}],youtube:[{version:null,types:["video/youtube","video/x-youtube","audio/youtube","audio/x-youtube"]}],vimeo:[{version:null,types:["video/vimeo", |
||||
"video/x-vimeo"]}]}; |
||||
mejs.Utility={encodeUrl:function(a){return encodeURIComponent(a)},escapeHTML:function(a){return a.toString().split("&").join("&").split("<").join("<").split('"').join(""")},absolutizeUrl:function(a){var b=document.createElement("div");b.innerHTML='<a href="'+this.escapeHTML(a)+'">x</a>';return b.firstChild.href},getScriptPath:function(a){for(var b=0,c,d="",e="",f,g,h=document.getElementsByTagName("script"),l=h.length,j=a.length;b<l;b++){f=h[b].src;c=f.lastIndexOf("/");if(c>-1){g=f.substring(c+ |
||||
1);f=f.substring(0,c+1)}else{g=f;f=""}for(c=0;c<j;c++){e=a[c];e=g.indexOf(e);if(e>-1){d=f;break}}if(d!=="")break}return d},secondsToTimeCode:function(a,b,c,d){if(typeof c=="undefined")c=false;else if(typeof d=="undefined")d=25;var e=Math.floor(a/3600)%24,f=Math.floor(a/60)%60,g=Math.floor(a%60);a=Math.floor((a%1*d).toFixed(3));return(b||e>0?(e<10?"0"+e:e)+":":"")+(f<10?"0"+f:f)+":"+(g<10?"0"+g:g)+(c?":"+(a<10?"0"+a:a):"")},timeCodeToSeconds:function(a,b,c,d){if(typeof c=="undefined")c=false;else if(typeof d== |
||||
"undefined")d=25;a=a.split(":");b=parseInt(a[0],10);var e=parseInt(a[1],10),f=parseInt(a[2],10),g=0,h=0;if(c)g=parseInt(a[3])/d;return h=b*3600+e*60+f+g},convertSMPTEtoSeconds:function(a){if(typeof a!="string")return false;a=a.replace(",",".");var b=0,c=a.indexOf(".")!=-1?a.split(".")[1].length:0,d=1;a=a.split(":").reverse();for(var e=0;e<a.length;e++){d=1;if(e>0)d=Math.pow(60,e);b+=Number(a[e])*d}return Number(b.toFixed(c))},removeSwf:function(a){var b=document.getElementById(a);if(b&&/object|embed/i.test(b.nodeName))if(mejs.MediaFeatures.isIE){b.style.display= |
||||
"none";(function(){b.readyState==4?mejs.Utility.removeObjectInIE(a):setTimeout(arguments.callee,10)})()}else b.parentNode.removeChild(b)},removeObjectInIE:function(a){if(a=document.getElementById(a)){for(var b in a)if(typeof a[b]=="function")a[b]=null;a.parentNode.removeChild(a)}}}; |
||||
mejs.PluginDetector={hasPluginVersion:function(a,b){var c=this.plugins[a];b[1]=b[1]||0;b[2]=b[2]||0;return c[0]>b[0]||c[0]==b[0]&&c[1]>b[1]||c[0]==b[0]&&c[1]==b[1]&&c[2]>=b[2]?true:false},nav:window.navigator,ua:window.navigator.userAgent.toLowerCase(),plugins:[],addPlugin:function(a,b,c,d,e){this.plugins[a]=this.detectPlugin(b,c,d,e)},detectPlugin:function(a,b,c,d){var e=[0,0,0],f;if(typeof this.nav.plugins!="undefined"&&typeof this.nav.plugins[a]=="object"){if((c=this.nav.plugins[a].description)&& |
||||
!(typeof this.nav.mimeTypes!="undefined"&&this.nav.mimeTypes[b]&&!this.nav.mimeTypes[b].enabledPlugin)){e=c.replace(a,"").replace(/^\s+/,"").replace(/\sr/gi,".").split(".");for(a=0;a<e.length;a++)e[a]=parseInt(e[a].match(/\d+/),10)}}else if(typeof window.ActiveXObject!="undefined")try{if(f=new ActiveXObject(c))e=d(f)}catch(g){}return e}}; |
||||
mejs.PluginDetector.addPlugin("flash","Shockwave Flash","application/x-shockwave-flash","ShockwaveFlash.ShockwaveFlash",function(a){var b=[];if(a=a.GetVariable("$version")){a=a.split(" ")[1].split(",");b=[parseInt(a[0],10),parseInt(a[1],10),parseInt(a[2],10)]}return b}); |
||||
mejs.PluginDetector.addPlugin("silverlight","Silverlight Plug-In","application/x-silverlight-2","AgControl.AgControl",function(a){var b=[0,0,0,0],c=function(d,e,f,g){for(;d.isVersionSupported(e[0]+"."+e[1]+"."+e[2]+"."+e[3]);)e[f]+=g;e[f]-=g};c(a,b,0,1);c(a,b,1,1);c(a,b,2,1E4);c(a,b,2,1E3);c(a,b,2,100);c(a,b,2,10);c(a,b,2,1);c(a,b,3,1);return b}); |
||||
mejs.MediaFeatures={init:function(){var a=this,b=document,c=mejs.PluginDetector.nav,d=mejs.PluginDetector.ua.toLowerCase(),e,f=["source","track","audio","video"];a.isiPad=d.match(/ipad/i)!==null;a.isiPhone=d.match(/iphone/i)!==null;a.isiOS=a.isiPhone||a.isiPad;a.isAndroid=d.match(/android/i)!==null;a.isBustedAndroid=d.match(/android 2\.[12]/)!==null;a.isBustedNativeHTTPS=location.protocol==="https:"&&(d.match(/android [12]\./)!==null||d.match(/macintosh.* version.* safari/)!==null);a.isIE=c.appName.toLowerCase().indexOf("microsoft")!= |
||||
-1;a.isChrome=d.match(/chrome/gi)!==null;a.isFirefox=d.match(/firefox/gi)!==null;a.isWebkit=d.match(/webkit/gi)!==null;a.isGecko=d.match(/gecko/gi)!==null&&!a.isWebkit;a.isOpera=d.match(/opera/gi)!==null;a.hasTouch="ontouchstart"in window&&window.ontouchstart!=null;a.svg=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect;for(c=0;c<f.length;c++)e=document.createElement(f[c]);a.supportsMediaTag=typeof e.canPlayType!=="undefined"||a.isBustedAndroid; |
||||
try{e.canPlayType("video/mp4")}catch(g){a.supportsMediaTag=false}a.hasSemiNativeFullScreen=typeof e.webkitEnterFullscreen!=="undefined";a.hasWebkitNativeFullScreen=typeof e.webkitRequestFullScreen!=="undefined";a.hasMozNativeFullScreen=typeof e.mozRequestFullScreen!=="undefined";a.hasTrueNativeFullScreen=a.hasWebkitNativeFullScreen||a.hasMozNativeFullScreen;a.nativeFullScreenEnabled=a.hasTrueNativeFullScreen;if(a.hasMozNativeFullScreen)a.nativeFullScreenEnabled=e.mozFullScreenEnabled;if(this.isChrome)a.hasSemiNativeFullScreen= |
||||
false;if(a.hasTrueNativeFullScreen){a.fullScreenEventName=a.hasWebkitNativeFullScreen?"webkitfullscreenchange":"mozfullscreenchange";a.isFullScreen=function(){if(e.mozRequestFullScreen)return b.mozFullScreen;else if(e.webkitRequestFullScreen)return b.webkitIsFullScreen};a.requestFullScreen=function(h){if(a.hasWebkitNativeFullScreen)h.webkitRequestFullScreen();else a.hasMozNativeFullScreen&&h.mozRequestFullScreen()};a.cancelFullScreen=function(){if(a.hasWebkitNativeFullScreen)document.webkitCancelFullScreen(); |
||||
else a.hasMozNativeFullScreen&&document.mozCancelFullScreen()}}if(a.hasSemiNativeFullScreen&&d.match(/mac os x 10_5/i)){a.hasNativeFullScreen=false;a.hasSemiNativeFullScreen=false}}};mejs.MediaFeatures.init(); |
||||
mejs.HtmlMediaElement={pluginType:"native",isFullScreen:false,setCurrentTime:function(a){this.currentTime=a},setMuted:function(a){this.muted=a},setVolume:function(a){this.volume=a},stop:function(){this.pause()},setSrc:function(a){for(var b=this.getElementsByTagName("source");b.length>0;)this.removeChild(b[0]);if(typeof a=="string")this.src=a;else{var c;for(b=0;b<a.length;b++){c=a[b];if(this.canPlayType(c.type)){this.src=c.src;break}}}},setVideoSize:function(a,b){this.width=a;this.height=b}}; |
||||
mejs.PluginMediaElement=function(a,b,c){this.id=a;this.pluginType=b;this.src=c;this.events={};this.attributes={}}; |
||||
mejs.PluginMediaElement.prototype={pluginElement:null,pluginType:"",isFullScreen:false,playbackRate:-1,defaultPlaybackRate:-1,seekable:[],played:[],paused:true,ended:false,seeking:false,duration:0,error:null,tagName:"",muted:false,volume:1,currentTime:0,play:function(){if(this.pluginApi!=null){this.pluginType=="youtube"?this.pluginApi.playVideo():this.pluginApi.playMedia();this.paused=false}},load:function(){if(this.pluginApi!=null){this.pluginType!="youtube"&&this.pluginApi.loadMedia();this.paused= |
||||
false}},pause:function(){if(this.pluginApi!=null){this.pluginType=="youtube"?this.pluginApi.pauseVideo():this.pluginApi.pauseMedia();this.paused=true}},stop:function(){if(this.pluginApi!=null){this.pluginType=="youtube"?this.pluginApi.stopVideo():this.pluginApi.stopMedia();this.paused=true}},canPlayType:function(a){var b,c,d,e=mejs.plugins[this.pluginType];for(b=0;b<e.length;b++){d=e[b];if(mejs.PluginDetector.hasPluginVersion(this.pluginType,d.version))for(c=0;c<d.types.length;c++)if(a==d.types[c])return"probably"}return""}, |
||||
positionFullscreenButton:function(a,b,c){this.pluginApi!=null&&this.pluginApi.positionFullscreenButton&&this.pluginApi.positionFullscreenButton(Math.floor(a),Math.floor(b),c)},hideFullscreenButton:function(){this.pluginApi!=null&&this.pluginApi.hideFullscreenButton&&this.pluginApi.hideFullscreenButton()},setSrc:function(a){if(typeof a=="string"){this.pluginApi.setSrc(mejs.Utility.absolutizeUrl(a));this.src=mejs.Utility.absolutizeUrl(a)}else{var b,c;for(b=0;b<a.length;b++){c=a[b];if(this.canPlayType(c.type)){this.pluginApi.setSrc(mejs.Utility.absolutizeUrl(c.src)); |
||||
this.src=mejs.Utility.absolutizeUrl(a);break}}}},setCurrentTime:function(a){if(this.pluginApi!=null){this.pluginType=="youtube"?this.pluginApi.seekTo(a):this.pluginApi.setCurrentTime(a);this.currentTime=a}},setVolume:function(a){if(this.pluginApi!=null){this.pluginType=="youtube"?this.pluginApi.setVolume(a*100):this.pluginApi.setVolume(a);this.volume=a}},setMuted:function(a){if(this.pluginApi!=null){if(this.pluginType=="youtube"){a?this.pluginApi.mute():this.pluginApi.unMute();this.muted=a;this.dispatchEvent("volumechange")}else this.pluginApi.setMuted(a); |
||||
this.muted=a}},setVideoSize:function(a,b){if(this.pluginElement.style){this.pluginElement.style.width=a+"px";this.pluginElement.style.height=b+"px"}this.pluginApi!=null&&this.pluginApi.setVideoSize&&this.pluginApi.setVideoSize(a,b)},setFullscreen:function(a){this.pluginApi!=null&&this.pluginApi.setFullscreen&&this.pluginApi.setFullscreen(a)},enterFullScreen:function(){this.pluginApi!=null&&this.pluginApi.setFullscreen&&this.setFullscreen(true)},exitFullScreen:function(){this.pluginApi!=null&&this.pluginApi.setFullscreen&& |
||||
this.setFullscreen(false)},addEventListener:function(a,b){this.events[a]=this.events[a]||[];this.events[a].push(b)},removeEventListener:function(a,b){if(!a){this.events={};return true}var c=this.events[a];if(!c)return true;if(!b){this.events[a]=[];return true}for(i=0;i<c.length;i++)if(c[i]===b){this.events[a].splice(i,1);return true}return false},dispatchEvent:function(a){var b,c,d=this.events[a];if(d){c=Array.prototype.slice.call(arguments,1);for(b=0;b<d.length;b++)d[b].apply(null,c)}},hasAttribute:function(a){return a in |
||||
this.attributes},removeAttribute:function(a){delete this.attributes[a]},getAttribute:function(a){if(this.hasAttribute(a))return this.attributes[a];return""},setAttribute:function(a,b){this.attributes[a]=b},remove:function(){mejs.Utility.removeSwf(this.pluginElement.id);mejs.MediaPluginBridge.unregisterPluginElement(this.pluginElement.id)}}; |
||||
mejs.MediaPluginBridge={pluginMediaElements:{},htmlMediaElements:{},registerPluginElement:function(a,b,c){this.pluginMediaElements[a]=b;this.htmlMediaElements[a]=c},unregisterPluginElement:function(a){delete this.pluginMediaElements[a];delete this.htmlMediaElements[a]},initPlugin:function(a){var b=this.pluginMediaElements[a],c=this.htmlMediaElements[a];if(b){switch(b.pluginType){case "flash":b.pluginElement=b.pluginApi=document.getElementById(a);break;case "silverlight":b.pluginElement=document.getElementById(b.id); |
||||
b.pluginApi=b.pluginElement.Content.MediaElementJS}b.pluginApi!=null&&b.success&&b.success(b,c)}},fireEvent:function(a,b,c){var d,e;if(a=this.pluginMediaElements[a]){b={type:b,target:a};for(d in c){a[d]=c[d];b[d]=c[d]}e=c.bufferedTime||0;b.target.buffered=b.buffered={start:function(){return 0},end:function(){return e},length:1};a.dispatchEvent(b.type,b)}}}; |
||||
mejs.MediaElementDefaults={mode:"auto",plugins:["flash","silverlight","youtube","vimeo"],enablePluginDebug:false,httpsBasicAuthSite:false,type:"",pluginPath:mejs.Utility.getScriptPath(["mediaelement.js","mediaelement.min.js","mediaelement-and-player.js","mediaelement-and-player.min.js"]),flashName:"flashmediaelement.swf",flashStreamer:"",enablePluginSmoothing:false,enablePseudoStreaming:false,pseudoStreamingStartQueryParam:"start",silverlightName:"silverlightmediaelement.xap",defaultVideoWidth:480, |
||||
defaultVideoHeight:270,pluginWidth:-1,pluginHeight:-1,pluginVars:[],timerRate:250,startVolume:0.8,success:function(){},error:function(){}};mejs.MediaElement=function(a,b){return mejs.HtmlMediaElementShim.create(a,b)}; |
||||
mejs.HtmlMediaElementShim={create:function(a,b){var c=mejs.MediaElementDefaults,d=typeof a=="string"?document.getElementById(a):a,e=d.tagName.toLowerCase(),f=e==="audio"||e==="video",g=f?d.getAttribute("src"):d.getAttribute("href");e=d.getAttribute("poster");var h=d.getAttribute("autoplay"),l=d.getAttribute("preload"),j=d.getAttribute("controls"),k;for(k in b)c[k]=b[k];g=typeof g=="undefined"||g===null||g==""?null:g;e=typeof e=="undefined"||e===null?"":e;l=typeof l=="undefined"||l===null||l==="false"? |
||||
"none":l;h=!(typeof h=="undefined"||h===null||h==="false");j=!(typeof j=="undefined"||j===null||j==="false");k=this.determinePlayback(d,c,mejs.MediaFeatures.supportsMediaTag,f,g);k.url=k.url!==null?mejs.Utility.absolutizeUrl(k.url):"";if(k.method=="native"){if(mejs.MediaFeatures.isBustedAndroid){d.src=k.url;d.addEventListener("click",function(){d.play()},false)}return this.updateNative(k,c,h,l)}else if(k.method!=="")return this.createPlugin(k,c,e,h,l,j);else{this.createErrorMessage(k,c,e);return this}}, |
||||
determinePlayback:function(a,b,c,d,e){var f=[],g,h,l,j={method:"",url:"",htmlMediaElement:a,isVideo:a.tagName.toLowerCase()!="audio"},k;if(typeof b.type!="undefined"&&b.type!=="")if(typeof b.type=="string")f.push({type:b.type,url:e});else for(g=0;g<b.type.length;g++)f.push({type:b.type[g],url:e});else if(e!==null){l=this.formatType(e,a.getAttribute("type"));f.push({type:l,url:e})}else for(g=0;g<a.childNodes.length;g++){h=a.childNodes[g];if(h.nodeType==1&&h.tagName.toLowerCase()=="source"){e=h.getAttribute("src"); |
||||
l=this.formatType(e,h.getAttribute("type"));h=h.getAttribute("media");if(!h||!window.matchMedia||window.matchMedia&&window.matchMedia(h).matches)f.push({type:l,url:e})}}if(!d&&f.length>0&&f[0].url!==null&&this.getTypeFromFile(f[0].url).indexOf("audio")>-1)j.isVideo=false;if(mejs.MediaFeatures.isBustedAndroid)a.canPlayType=function(m){return m.match(/video\/(mp4|m4v)/gi)!==null?"maybe":""};if(c&&(b.mode==="auto"||b.mode==="auto_plugin"||b.mode==="native")&&!(mejs.MediaFeatures.isBustedNativeHTTPS&& |
||||
b.httpsBasicAuthSite===true)){if(!d){g=document.createElement(j.isVideo?"video":"audio");a.parentNode.insertBefore(g,a);a.style.display="none";j.htmlMediaElement=a=g}for(g=0;g<f.length;g++)if(a.canPlayType(f[g].type).replace(/no/,"")!==""||a.canPlayType(f[g].type.replace(/mp3/,"mpeg")).replace(/no/,"")!==""){j.method="native";j.url=f[g].url;break}if(j.method==="native"){if(j.url!==null)a.src=j.url;if(b.mode!=="auto_plugin")return j}}if(b.mode==="auto"||b.mode==="auto_plugin"||b.mode==="shim")for(g= |
||||
0;g<f.length;g++){l=f[g].type;for(a=0;a<b.plugins.length;a++){e=b.plugins[a];h=mejs.plugins[e];for(c=0;c<h.length;c++){k=h[c];if(k.version==null||mejs.PluginDetector.hasPluginVersion(e,k.version))for(d=0;d<k.types.length;d++)if(l==k.types[d]){j.method=e;j.url=f[g].url;return j}}}}if(b.mode==="auto_plugin"&&j.method==="native")return j;if(j.method===""&&f.length>0)j.url=f[0].url;return j},formatType:function(a,b){return a&&!b?this.getTypeFromFile(a):b&&~b.indexOf(";")?b.substr(0,b.indexOf(";")):b}, |
||||
getTypeFromFile:function(a){a=a.split("?")[0];a=a.substring(a.lastIndexOf(".")+1).toLowerCase();return(/(mp4|m4v|ogg|ogv|webm|webmv|flv|wmv|mpeg|mov)/gi.test(a)?"video":"audio")+"/"+this.getTypeFromExtension(a)},getTypeFromExtension:function(a){switch(a){case "mp4":case "m4v":return"mp4";case "webm":case "webma":case "webmv":return"webm";case "ogg":case "oga":case "ogv":return"ogg";default:return a}},createErrorMessage:function(a,b,c){var d=a.htmlMediaElement,e=document.createElement("div");e.className= |
||||
"me-cannotplay";try{e.style.width=d.width+"px";e.style.height=d.height+"px"}catch(f){}e.innerHTML=b.customError?b.customError:c!==""?'<a href="'+a.url+'"><img src="'+c+'" width="100%" height="100%" /></a>':'<a href="'+a.url+'"><span>'+mejs.i18n.t("Download File")+"</span></a>";d.parentNode.insertBefore(e,d);d.style.display="none";b.error(d)},createPlugin:function(a,b,c,d,e,f){c=a.htmlMediaElement;var g=1,h=1,l="me_"+a.method+"_"+mejs.meIndex++,j=new mejs.PluginMediaElement(l,a.method,a.url),k=document.createElement("div"), |
||||
m;j.tagName=c.tagName;for(m=0;m<c.attributes.length;m++){var n=c.attributes[m];n.specified==true&&j.setAttribute(n.name,n.value)}for(m=c.parentNode;m!==null&&m.tagName.toLowerCase()!="body";){if(m.parentNode.tagName.toLowerCase()=="p"){m.parentNode.parentNode.insertBefore(m,m.parentNode);break}m=m.parentNode}if(a.isVideo){g=b.pluginWidth>0?b.pluginWidth:b.videoWidth>0?b.videoWidth:c.getAttribute("width")!==null?c.getAttribute("width"):b.defaultVideoWidth;h=b.pluginHeight>0?b.pluginHeight:b.videoHeight> |
||||
0?b.videoHeight:c.getAttribute("height")!==null?c.getAttribute("height"):b.defaultVideoHeight;g=mejs.Utility.encodeUrl(g);h=mejs.Utility.encodeUrl(h)}else if(b.enablePluginDebug){g=320;h=240}j.success=b.success;mejs.MediaPluginBridge.registerPluginElement(l,j,c);k.className="me-plugin";k.id=l+"_container";a.isVideo?c.parentNode.insertBefore(k,c):document.body.insertBefore(k,document.body.childNodes[0]);d=["id="+l,"isvideo="+(a.isVideo?"true":"false"),"autoplay="+(d?"true":"false"),"preload="+e,"width="+ |
||||
g,"startvolume="+b.startVolume,"timerrate="+b.timerRate,"flashstreamer="+b.flashStreamer,"height="+h,"pseudostreamstart="+b.pseudoStreamingStartQueryParam];if(a.url!==null)a.method=="flash"?d.push("file="+mejs.Utility.encodeUrl(a.url)):d.push("file="+a.url);b.enablePluginDebug&&d.push("debug=true");b.enablePluginSmoothing&&d.push("smoothing=true");b.enablePseudoStreaming&&d.push("pseudostreaming=true");f&&d.push("controls=true");if(b.pluginVars)d=d.concat(b.pluginVars);switch(a.method){case "silverlight":k.innerHTML= |
||||
'<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" id="'+l+'" name="'+l+'" width="'+g+'" height="'+h+'" class="mejs-shim"><param name="initParams" value="'+d.join(",")+'" /><param name="windowless" value="true" /><param name="background" value="black" /><param name="minRuntimeVersion" value="3.0.0.0" /><param name="autoUpgrade" value="true" /><param name="source" value="'+b.pluginPath+b.silverlightName+'" /></object>';break;case "flash":if(mejs.MediaFeatures.isIE){a= |
||||
document.createElement("div");k.appendChild(a);a.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" id="'+l+'" width="'+g+'" height="'+h+'" class="mejs-shim"><param name="movie" value="'+b.pluginPath+b.flashName+"?x="+new Date+'" /><param name="flashvars" value="'+d.join("&")+'" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /></object>'}else k.innerHTML= |
||||
'<embed id="'+l+'" name="'+l+'" play="true" loop="false" quality="high" bgcolor="#000000" wmode="transparent" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="//www.macromedia.com/go/getflashplayer" src="'+b.pluginPath+b.flashName+'" flashvars="'+d.join("&")+'" width="'+g+'" height="'+h+'" class="mejs-shim"></embed>';break;case "youtube":b=a.url.substr(a.url.lastIndexOf("=")+1);youtubeSettings={container:k,containerId:k.id,pluginMediaElement:j,pluginId:l, |
||||
videoId:b,height:h,width:g};mejs.PluginDetector.hasPluginVersion("flash",[10,0,0])?mejs.YouTubeApi.createFlash(youtubeSettings):mejs.YouTubeApi.enqueueIframe(youtubeSettings);break;case "vimeo":j.vimeoid=a.url.substr(a.url.lastIndexOf("/")+1);k.innerHTML='<iframe src="http://player.vimeo.com/video/'+j.vimeoid+'?portrait=0&byline=0&title=0" width="'+g+'" height="'+h+'" frameborder="0" class="mejs-shim"></iframe>'}c.style.display="none";c.removeAttribute("autoplay");return j},updateNative:function(a, |
||||
b){var c=a.htmlMediaElement,d;for(d in mejs.HtmlMediaElement)c[d]=mejs.HtmlMediaElement[d];b.success(c,c);return c}}; |
||||
mejs.YouTubeApi={isIframeStarted:false,isIframeLoaded:false,loadIframeApi:function(){if(!this.isIframeStarted){var a=document.createElement("script");a.src="//www.youtube.com/player_api";var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b);this.isIframeStarted=true}},iframeQueue:[],enqueueIframe:function(a){if(this.isLoaded)this.createIframe(a);else{this.loadIframeApi();this.iframeQueue.push(a)}},createIframe:function(a){var b=a.pluginMediaElement,c=new YT.Player(a.containerId, |
||||
{height:a.height,width:a.width,videoId:a.videoId,playerVars:{controls:0},events:{onReady:function(){a.pluginMediaElement.pluginApi=c;mejs.MediaPluginBridge.initPlugin(a.pluginId);setInterval(function(){mejs.YouTubeApi.createEvent(c,b,"timeupdate")},250)},onStateChange:function(d){mejs.YouTubeApi.handleStateChange(d.data,c,b)}}})},createEvent:function(a,b,c){c={type:c,target:b};if(a&&a.getDuration){b.currentTime=c.currentTime=a.getCurrentTime();b.duration=c.duration=a.getDuration();c.paused=b.paused; |
||||
c.ended=b.ended;c.muted=a.isMuted();c.volume=a.getVolume()/100;c.bytesTotal=a.getVideoBytesTotal();c.bufferedBytes=a.getVideoBytesLoaded();var d=c.bufferedBytes/c.bytesTotal*c.duration;c.target.buffered=c.buffered={start:function(){return 0},end:function(){return d},length:1}}b.dispatchEvent(c.type,c)},iFrameReady:function(){for(this.isIframeLoaded=this.isLoaded=true;this.iframeQueue.length>0;)this.createIframe(this.iframeQueue.pop())},flashPlayers:{},createFlash:function(a){this.flashPlayers[a.pluginId]= |
||||
a;var b,c="//www.youtube.com/apiplayer?enablejsapi=1&playerapiid="+a.pluginId+"&version=3&autoplay=0&controls=0&modestbranding=1&loop=0";if(mejs.MediaFeatures.isIE){b=document.createElement("div");a.container.appendChild(b);b.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" id="'+a.pluginId+'" width="'+a.width+'" height="'+a.height+'" class="mejs-shim"><param name="movie" value="'+ |
||||
c+'" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /></object>'}else a.container.innerHTML='<object type="application/x-shockwave-flash" id="'+a.pluginId+'" data="'+c+'" width="'+a.width+'" height="'+a.height+'" style="visibility: visible; " class="mejs-shim"><param name="allowScriptAccess" value="always"><param name="wmode" value="transparent"></object>'},flashReady:function(a){var b=this.flashPlayers[a],c= |
||||
document.getElementById(a),d=b.pluginMediaElement;d.pluginApi=d.pluginElement=c;mejs.MediaPluginBridge.initPlugin(a);c.cueVideoById(b.videoId);a=b.containerId+"_callback";window[a]=function(e){mejs.YouTubeApi.handleStateChange(e,c,d)};c.addEventListener("onStateChange",a);setInterval(function(){mejs.YouTubeApi.createEvent(c,d,"timeupdate")},250)},handleStateChange:function(a,b,c){switch(a){case -1:c.paused=true;c.ended=true;mejs.YouTubeApi.createEvent(b,c,"loadedmetadata");break;case 0:c.paused=false; |
||||
c.ended=true;mejs.YouTubeApi.createEvent(b,c,"ended");break;case 1:c.paused=false;c.ended=false;mejs.YouTubeApi.createEvent(b,c,"play");mejs.YouTubeApi.createEvent(b,c,"playing");break;case 2:c.paused=true;c.ended=false;mejs.YouTubeApi.createEvent(b,c,"pause");break;case 3:mejs.YouTubeApi.createEvent(b,c,"progress")}}};function onYouTubePlayerAPIReady(){mejs.YouTubeApi.iFrameReady()}function onYouTubePlayerReady(a){mejs.YouTubeApi.flashReady(a)}window.mejs=mejs;window.MediaElement=mejs.MediaElement; |
||||
(function(a,b){var c={locale:{language:"",strings:{}},methods:{}};c.locale.getLanguage=function(){return c.locale.language||navigator.language};if(typeof mejsL10n!="undefined")c.locale.language=mejsL10n.language;c.locale.INIT_LANGUAGE=c.locale.getLanguage();c.methods.checkPlain=function(d){var e,f,g={"&":"&",'"':""","<":"<",">":">"};d=String(d);for(e in g)if(g.hasOwnProperty(e)){f=RegExp(e,"g");d=d.replace(f,g[e])}return d};c.methods.formatString=function(d,e){for(var f in e){switch(f.charAt(0)){case "@":e[f]= |
||||
c.methods.checkPlain(e[f]);break;case "!":break;default:e[f]='<em class="placeholder">'+c.methods.checkPlain(e[f])+"</em>"}d=d.replace(f,e[f])}return d};c.methods.t=function(d,e,f){if(c.locale.strings&&c.locale.strings[f.context]&&c.locale.strings[f.context][d])d=c.locale.strings[f.context][d];if(e)d=c.methods.formatString(d,e);return d};c.t=function(d,e,f){if(typeof d==="string"&&d.length>0){var g=c.locale.getLanguage();f=f||{context:g};return c.methods.t(d,e,f)}else throw{name:"InvalidArgumentException", |
||||
message:"First argument is either not a string or empty."};};b.i18n=c})(document,mejs);(function(a){if(typeof mejsL10n!="undefined")a[mejsL10n.language]=mejsL10n.strings})(mejs.i18n.locale.strings);(function(a){a.de={Fullscreen:"Vollbild","Go Fullscreen":"Vollbild an","Turn off Fullscreen":"Vollbild aus",Close:"Schlie\u00dfen"}})(mejs.i18n.locale.strings); |
||||
(function(a){a.zh={Fullscreen:"\u5168\u87a2\u5e55","Go Fullscreen":"\u5168\u5c4f\u6a21\u5f0f","Turn off Fullscreen":"\u9000\u51fa\u5168\u5c4f\u6a21\u5f0f",Close:"\u95dc\u9589"}})(mejs.i18n.locale.strings); |
||||
|
||||
/*! |
||||
* MediaElementPlayer |
||||
* http://mediaelementjs.com/
|
||||
* |
||||
* Creates a controller bar for HTML5 <video> add <audio> tags |
||||
* using jQuery and MediaElement.js (HTML5 Flash/Silverlight wrapper) |
||||
* |
||||
* Copyright 2010-2013, John Dyer (http://j.hn/)
|
||||
* License: MIT |
||||
* |
||||
*/if(typeof jQuery!="undefined")mejs.$=jQuery;else if(typeof ender!="undefined")mejs.$=ender; |
||||
(function(f){mejs.MepDefaults={poster:"",showPosterWhenEnded:false,defaultVideoWidth:480,defaultVideoHeight:270,videoWidth:-1,videoHeight:-1,defaultAudioWidth:400,defaultAudioHeight:30,defaultSeekBackwardInterval:function(a){return a.duration*0.05},defaultSeekForwardInterval:function(a){return a.duration*0.05},audioWidth:-1,audioHeight:-1,startVolume:0.8,loop:false,autoRewind:true,enableAutosize:true,alwaysShowHours:false,showTimecodeFrameCount:false,framesPerSecond:25,autosizeProgress:true,alwaysShowControls:false, |
||||
hideVideoControlsOnLoad:false,clickToPlayPause:true,iPadUseNativeControls:false,iPhoneUseNativeControls:false,AndroidUseNativeControls:false,features:["playpause","current","progress","duration","tracks","volume","fullscreen"],isVideo:true,enableKeyboard:true,pauseOtherPlayers:true,keyActions:[{keys:[32,179],action:function(a,b){b.paused||b.ended?b.play():b.pause()}},{keys:[38],action:function(a,b){b.setVolume(Math.min(b.volume+0.1,1))}},{keys:[40],action:function(a,b){b.setVolume(Math.max(b.volume- |
||||
0.1,0))}},{keys:[37,227],action:function(a,b){if(!isNaN(b.duration)&&b.duration>0){if(a.isVideo){a.showControls();a.startControlsTimer()}var c=Math.max(b.currentTime-a.options.defaultSeekBackwardInterval(b),0);b.setCurrentTime(c)}}},{keys:[39,228],action:function(a,b){if(!isNaN(b.duration)&&b.duration>0){if(a.isVideo){a.showControls();a.startControlsTimer()}var c=Math.min(b.currentTime+a.options.defaultSeekForwardInterval(b),b.duration);b.setCurrentTime(c)}}},{keys:[70],action:function(a){if(typeof a.enterFullScreen!= |
||||
"undefined")a.isFullScreen?a.exitFullScreen():a.enterFullScreen()}}]};mejs.mepIndex=0;mejs.players={};mejs.MediaElementPlayer=function(a,b){if(!(this instanceof mejs.MediaElementPlayer))return new mejs.MediaElementPlayer(a,b);this.$media=this.$node=f(a);this.node=this.media=this.$media[0];if(typeof this.node.player!="undefined")return this.node.player;else this.node.player=this;if(typeof b=="undefined")b=this.$node.data("mejsoptions");this.options=f.extend({},mejs.MepDefaults,b);this.id="mep_"+mejs.mepIndex++; |
||||
mejs.players[this.id]=this;this.init();return this};mejs.MediaElementPlayer.prototype={hasFocus:false,controlsAreVisible:true,init:function(){var a=this,b=mejs.MediaFeatures,c=f.extend(true,{},a.options,{success:function(d,g){a.meReady(d,g)},error:function(d){a.handleError(d)}}),e=a.media.tagName.toLowerCase();a.isDynamic=e!=="audio"&&e!=="video";a.isVideo=a.isDynamic?a.options.isVideo:e!=="audio"&&a.options.isVideo;if(b.isiPad&&a.options.iPadUseNativeControls||b.isiPhone&&a.options.iPhoneUseNativeControls){a.$media.attr("controls", |
||||
"controls");if(b.isiPad&&a.media.getAttribute("autoplay")!==null){a.media.load();a.media.play()}}else if(!(b.isAndroid&&a.options.AndroidUseNativeControls)){a.$media.removeAttr("controls");a.container=f('<div id="'+a.id+'" class="mejs-container '+(mejs.MediaFeatures.svg?"svg":"no-svg")+'"><div class="mejs-inner"><div class="mejs-mediaelement"></div><div class="mejs-layers"></div><div class="mejs-controls"></div><div class="mejs-clear"></div></div></div>').addClass(a.$media[0].className).insertBefore(a.$media); |
||||
a.container.addClass((b.isAndroid?"mejs-android ":"")+(b.isiOS?"mejs-ios ":"")+(b.isiPad?"mejs-ipad ":"")+(b.isiPhone?"mejs-iphone ":"")+(a.isVideo?"mejs-video ":"mejs-audio "));if(b.isiOS){b=a.$media.clone();a.container.find(".mejs-mediaelement").append(b);a.$media.remove();a.$node=a.$media=b;a.node=a.media=b[0]}else a.container.find(".mejs-mediaelement").append(a.$media);a.controls=a.container.find(".mejs-controls");a.layers=a.container.find(".mejs-layers");b=a.isVideo?"video":"audio";e=b.substring(0, |
||||
1).toUpperCase()+b.substring(1);a.width=a.options[b+"Width"]>0||a.options[b+"Width"].toString().indexOf("%")>-1?a.options[b+"Width"]:a.media.style.width!==""&&a.media.style.width!==null?a.media.style.width:a.media.getAttribute("width")!==null?a.$media.attr("width"):a.options["default"+e+"Width"];a.height=a.options[b+"Height"]>0||a.options[b+"Height"].toString().indexOf("%")>-1?a.options[b+"Height"]:a.media.style.height!==""&&a.media.style.height!==null?a.media.style.height:a.$media[0].getAttribute("height")!== |
||||
null?a.$media.attr("height"):a.options["default"+e+"Height"];a.setPlayerSize(a.width,a.height);c.pluginWidth=a.width;c.pluginHeight=a.height}mejs.MediaElement(a.$media[0],c);typeof a.container!="undefined"&&a.controlsAreVisible&&a.container.trigger("controlsshown")},showControls:function(a){var b=this;a=typeof a=="undefined"||a;if(!b.controlsAreVisible){if(a){b.controls.css("visibility","visible").stop(true,true).fadeIn(200,function(){b.controlsAreVisible=true;b.container.trigger("controlsshown")}); |
||||
b.container.find(".mejs-control").css("visibility","visible").stop(true,true).fadeIn(200,function(){b.controlsAreVisible=true})}else{b.controls.css("visibility","visible").css("display","block");b.container.find(".mejs-control").css("visibility","visible").css("display","block");b.controlsAreVisible=true;b.container.trigger("controlsshown")}b.setControlsSize()}},hideControls:function(a){var b=this;a=typeof a=="undefined"||a;if(!(!b.controlsAreVisible||b.options.alwaysShowControls))if(a){b.controls.stop(true, |
||||
true).fadeOut(200,function(){f(this).css("visibility","hidden").css("display","block");b.controlsAreVisible=false;b.container.trigger("controlshidden")});b.container.find(".mejs-control").stop(true,true).fadeOut(200,function(){f(this).css("visibility","hidden").css("display","block")})}else{b.controls.css("visibility","hidden").css("display","block");b.container.find(".mejs-control").css("visibility","hidden").css("display","block");b.controlsAreVisible=false;b.container.trigger("controlshidden")}}, |
||||
controlsTimer:null,startControlsTimer:function(a){var b=this;a=typeof a!="undefined"?a:1500;b.killControlsTimer("start");b.controlsTimer=setTimeout(function(){b.hideControls();b.killControlsTimer("hide")},a)},killControlsTimer:function(){if(this.controlsTimer!==null){clearTimeout(this.controlsTimer);delete this.controlsTimer;this.controlsTimer=null}},controlsEnabled:true,disableControls:function(){this.killControlsTimer();this.hideControls(false);this.controlsEnabled=false},enableControls:function(){this.showControls(false); |
||||
this.controlsEnabled=true},meReady:function(a,b){var c=this,e=mejs.MediaFeatures,d=b.getAttribute("autoplay");d=!(typeof d=="undefined"||d===null||d==="false");var g;if(!c.created){c.created=true;c.media=a;c.domNode=b;if(!(e.isAndroid&&c.options.AndroidUseNativeControls)&&!(e.isiPad&&c.options.iPadUseNativeControls)&&!(e.isiPhone&&c.options.iPhoneUseNativeControls)){c.buildposter(c,c.controls,c.layers,c.media);c.buildkeyboard(c,c.controls,c.layers,c.media);c.buildoverlays(c,c.controls,c.layers,c.media); |
||||
c.findTracks();for(g in c.options.features){e=c.options.features[g];if(c["build"+e])try{c["build"+e](c,c.controls,c.layers,c.media)}catch(k){}}c.container.trigger("controlsready");c.setPlayerSize(c.width,c.height);c.setControlsSize();if(c.isVideo){if(mejs.MediaFeatures.hasTouch)c.$media.bind("touchstart",function(){if(c.controlsAreVisible)c.hideControls(false);else c.controlsEnabled&&c.showControls(false)});else{mejs.MediaElementPlayer.prototype.clickToPlayPauseCallback=function(){if(c.options.clickToPlayPause)c.media.paused? |
||||
c.media.play():c.media.pause()};c.media.addEventListener("click",c.clickToPlayPauseCallback,false);c.container.bind("mouseenter mouseover",function(){if(c.controlsEnabled)if(!c.options.alwaysShowControls){c.killControlsTimer("enter");c.showControls();c.startControlsTimer(2500)}}).bind("mousemove",function(){if(c.controlsEnabled){c.controlsAreVisible||c.showControls();c.options.alwaysShowControls||c.startControlsTimer(2500)}}).bind("mouseleave",function(){c.controlsEnabled&&!c.media.paused&&!c.options.alwaysShowControls&& |
||||
c.startControlsTimer(1E3)})}c.options.hideVideoControlsOnLoad&&c.hideControls(false);d&&!c.options.alwaysShowControls&&c.hideControls();c.options.enableAutosize&&c.media.addEventListener("loadedmetadata",function(j){if(c.options.videoHeight<=0&&c.domNode.getAttribute("height")===null&&!isNaN(j.target.videoHeight)){c.setPlayerSize(j.target.videoWidth,j.target.videoHeight);c.setControlsSize();c.media.setVideoSize(j.target.videoWidth,j.target.videoHeight)}},false)}a.addEventListener("play",function(){for(var j in mejs.players){var m= |
||||
mejs.players[j];m.id!=c.id&&c.options.pauseOtherPlayers&&!m.paused&&!m.ended&&m.pause();m.hasFocus=false}c.hasFocus=true},false);c.media.addEventListener("ended",function(){if(c.options.autoRewind)try{c.media.setCurrentTime(0)}catch(j){}c.media.pause();c.setProgressRail&&c.setProgressRail();c.setCurrentRail&&c.setCurrentRail();if(c.options.loop)c.media.play();else!c.options.alwaysShowControls&&c.controlsEnabled&&c.showControls()},false);c.media.addEventListener("loadedmetadata",function(){c.updateDuration&& |
||||
c.updateDuration();c.updateCurrent&&c.updateCurrent();if(!c.isFullScreen){c.setPlayerSize(c.width,c.height);c.setControlsSize()}},false);setTimeout(function(){c.setPlayerSize(c.width,c.height);c.setControlsSize()},50);c.globalBind("resize",function(){c.isFullScreen||mejs.MediaFeatures.hasTrueNativeFullScreen&&document.webkitIsFullScreen||c.setPlayerSize(c.width,c.height);c.setControlsSize()});c.media.pluginType=="youtube"&&c.container.find(".mejs-overlay-play").hide()}if(d&&a.pluginType=="native"){a.load(); |
||||
a.play()}if(c.options.success)typeof c.options.success=="string"?window[c.options.success](c.media,c.domNode,c):c.options.success(c.media,c.domNode,c)}},handleError:function(a){this.controls.hide();this.options.error&&this.options.error(a)},setPlayerSize:function(a,b){if(typeof a!="undefined")this.width=a;if(typeof b!="undefined")this.height=b;if(this.height.toString().indexOf("%")>0||this.$node.css("max-width")==="100%"||parseInt(this.$node.css("max-width").replace(/px/,""),10)/this.$node.offsetParent().width()=== |
||||
1||this.$node[0].currentStyle&&this.$node[0].currentStyle.maxWidth==="100%"){var c=this.isVideo?this.media.videoWidth&&this.media.videoWidth>0?this.media.videoWidth:this.options.defaultVideoWidth:this.options.defaultAudioWidth,e=this.isVideo?this.media.videoHeight&&this.media.videoHeight>0?this.media.videoHeight:this.options.defaultVideoHeight:this.options.defaultAudioHeight,d=this.container.parent().closest(":visible").width();c=this.isVideo||!this.options.autosizeProgress?parseInt(d*e/c,10):e;if(this.container.parent()[0].tagName.toLowerCase()=== |
||||
"body"){d=f(window).width();c=f(window).height()}if(c!=0&&d!=0){this.container.width(d).height(c);this.$media.add(this.container.find(".mejs-shim")).width("100%").height("100%");this.isVideo&&this.media.setVideoSize&&this.media.setVideoSize(d,c);this.layers.children(".mejs-layer").width("100%").height("100%")}}else{this.container.width(this.width).height(this.height);this.layers.children(".mejs-layer").width(this.width).height(this.height)}d=this.layers.find(".mejs-overlay-play");c=d.find(".mejs-overlay-button"); |
||||
d.height(this.container.height()-this.controls.height());c.css("margin-top","-"+(c.height()/2-this.controls.height()/2).toString()+"px")},setControlsSize:function(){var a=0,b=0,c=this.controls.find(".mejs-time-rail"),e=this.controls.find(".mejs-time-total");this.controls.find(".mejs-time-current");this.controls.find(".mejs-time-loaded");var d=c.siblings();if(this.options&&!this.options.autosizeProgress)b=parseInt(c.css("width"));if(b===0||!b){d.each(function(){var g=f(this);if(g.css("position")!= |
||||
"absolute"&&g.is(":visible"))a+=f(this).outerWidth(true)});b=this.controls.width()-a-(c.outerWidth(true)-c.width())}c.width(b);e.width(b-(e.outerWidth(true)-e.width()));this.setProgressRail&&this.setProgressRail();this.setCurrentRail&&this.setCurrentRail()},buildposter:function(a,b,c,e){var d=f('<div class="mejs-poster mejs-layer"></div>').appendTo(c);b=a.$media.attr("poster");if(a.options.poster!=="")b=a.options.poster;b!==""&&b!=null?this.setPoster(b):d.hide();e.addEventListener("play",function(){d.hide()}, |
||||
false);a.options.showPosterWhenEnded&&a.options.autoRewind&&e.addEventListener("ended",function(){d.show()},false)},setPoster:function(a){var b=this.container.find(".mejs-poster"),c=b.find("img");if(c.length==0)c=f('<img width="100%" height="100%" />').appendTo(b);c.attr("src",a);b.css({"background-image":"url("+a+")"})},buildoverlays:function(a,b,c,e){var d=this;if(a.isVideo){var g=f('<div class="mejs-overlay mejs-layer"><div class="mejs-overlay-loading"><span></span></div></div>').hide().appendTo(c), |
||||
k=f('<div class="mejs-overlay mejs-layer"><div class="mejs-overlay-error"></div></div>').hide().appendTo(c),j=f('<div class="mejs-overlay mejs-layer mejs-overlay-play"><div class="mejs-overlay-button"></div></div>').appendTo(c).click(function(){if(d.options.clickToPlayPause)e.paused?e.play():e.pause()});e.addEventListener("play",function(){j.hide();g.hide();b.find(".mejs-time-buffering").hide();k.hide()},false);e.addEventListener("playing",function(){j.hide();g.hide();b.find(".mejs-time-buffering").hide(); |
||||
k.hide()},false);e.addEventListener("seeking",function(){g.show();b.find(".mejs-time-buffering").show()},false);e.addEventListener("seeked",function(){g.hide();b.find(".mejs-time-buffering").hide()},false);e.addEventListener("pause",function(){mejs.MediaFeatures.isiPhone||j.show()},false);e.addEventListener("waiting",function(){g.show();b.find(".mejs-time-buffering").show()},false);e.addEventListener("loadeddata",function(){g.show();b.find(".mejs-time-buffering").show()},false);e.addEventListener("canplay", |
||||
function(){g.hide();b.find(".mejs-time-buffering").hide()},false);e.addEventListener("error",function(){g.hide();b.find(".mejs-time-buffering").hide();k.show();k.find("mejs-overlay-error").html("Error loading this resource")},false)}},buildkeyboard:function(a,b,c,e){this.globalBind("keydown",function(d){if(a.hasFocus&&a.options.enableKeyboard)for(var g=0,k=a.options.keyActions.length;g<k;g++)for(var j=a.options.keyActions[g],m=0,q=j.keys.length;m<q;m++)if(d.keyCode==j.keys[m]){d.preventDefault(); |
||||
j.action(a,e,d.keyCode);return false}return true});this.globalBind("click",function(d){if(f(d.target).closest(".mejs-container").length==0)a.hasFocus=false})},findTracks:function(){var a=this,b=a.$media.find("track");a.tracks=[];b.each(function(c,e){e=f(e);a.tracks.push({srclang:e.attr("srclang")?e.attr("srclang").toLowerCase():"",src:e.attr("src"),kind:e.attr("kind"),label:e.attr("label")||"",entries:[],isLoaded:false})})},changeSkin:function(a){this.container[0].className="mejs-container "+a;this.setPlayerSize(this.width, |
||||
this.height);this.setControlsSize()},play:function(){this.media.play()},pause:function(){try{this.media.pause()}catch(a){}},load:function(){this.media.load()},setMuted:function(a){this.media.setMuted(a)},setCurrentTime:function(a){this.media.setCurrentTime(a)},getCurrentTime:function(){return this.media.currentTime},setVolume:function(a){this.media.setVolume(a)},getVolume:function(){return this.media.volume},setSrc:function(a){this.media.setSrc(a)},remove:function(){var a,b;for(a in this.options.features){b= |
||||
this.options.features[a];if(this["clean"+b])try{this["clean"+b](this)}catch(c){}}if(this.isDynamic)this.$node.insertBefore(this.container);else{this.$media.prop("controls",true);this.$node.clone().show().insertBefore(this.container);this.$node.remove()}this.media.pluginType!=="native"&&this.media.remove();delete mejs.players[this.id];this.container.remove();this.globalUnbind();delete this.node.player}};(function(){function a(c,e){var d={d:[],w:[]};f.each((c||"").split(" "),function(g,k){var j=k+"."+ |
||||
e;if(j.indexOf(".")===0){d.d.push(j);d.w.push(j)}else d[b.test(k)?"w":"d"].push(j)});d.d=d.d.join(" ");d.w=d.w.join(" ");return d}var b=/^((after|before)print|(before)?unload|hashchange|message|o(ff|n)line|page(hide|show)|popstate|resize|storage)\b/;mejs.MediaElementPlayer.prototype.globalBind=function(c,e,d){c=a(c,this.id);c.d&&f(document).bind(c.d,e,d);c.w&&f(window).bind(c.w,e,d)};mejs.MediaElementPlayer.prototype.globalUnbind=function(c,e){c=a(c,this.id);c.d&&f(document).unbind(c.d,e);c.w&&f(window).unbind(c.w, |
||||
e)}})();if(typeof jQuery!="undefined")jQuery.fn.mediaelementplayer=function(a){a===false?this.each(function(){var b=jQuery(this).data("mediaelementplayer");b&&b.remove();jQuery(this).removeData("mediaelementplayer")}):this.each(function(){jQuery(this).data("mediaelementplayer",new mejs.MediaElementPlayer(this,a))});return this};f(document).ready(function(){f(".mejs-player").mediaelementplayer()});window.MediaElementPlayer=mejs.MediaElementPlayer})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{playpauseText:mejs.i18n.t("Play/Pause")});f.extend(MediaElementPlayer.prototype,{buildplaypause:function(a,b,c,e){var d=f('<div class="mejs-button mejs-playpause-button mejs-play" ><button type="button" aria-controls="'+this.id+'" title="'+this.options.playpauseText+'" aria-label="'+this.options.playpauseText+'"></button></div>').appendTo(b).click(function(g){g.preventDefault();e.paused?e.play():e.pause();return false});e.addEventListener("play",function(){d.removeClass("mejs-play").addClass("mejs-pause")}, |
||||
false);e.addEventListener("playing",function(){d.removeClass("mejs-play").addClass("mejs-pause")},false);e.addEventListener("pause",function(){d.removeClass("mejs-pause").addClass("mejs-play")},false);e.addEventListener("paused",function(){d.removeClass("mejs-pause").addClass("mejs-play")},false)}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{stopText:"Stop"});f.extend(MediaElementPlayer.prototype,{buildstop:function(a,b,c,e){f('<div class="mejs-button mejs-stop-button mejs-stop"><button type="button" aria-controls="'+this.id+'" title="'+this.options.stopText+'" aria-label="'+this.options.stopText+'"></button></div>').appendTo(b).click(function(){e.paused||e.pause();if(e.currentTime>0){e.setCurrentTime(0);e.pause();b.find(".mejs-time-current").width("0px");b.find(".mejs-time-handle").css("left", |
||||
"0px");b.find(".mejs-time-float-current").html(mejs.Utility.secondsToTimeCode(0));b.find(".mejs-currenttime").html(mejs.Utility.secondsToTimeCode(0));c.find(".mejs-poster").show()}})}})})(mejs.$); |
||||
(function(f){f.extend(MediaElementPlayer.prototype,{buildprogress:function(a,b,c,e){f('<div class="mejs-time-rail"><span class="mejs-time-total"><span class="mejs-time-buffering"></span><span class="mejs-time-loaded"></span><span class="mejs-time-current"></span><span class="mejs-time-handle"></span><span class="mejs-time-float"><span class="mejs-time-float-current">00:00</span><span class="mejs-time-float-corner"></span></span></span></div>').appendTo(b);b.find(".mejs-time-buffering").hide();var d= |
||||
this,g=b.find(".mejs-time-total");c=b.find(".mejs-time-loaded");var k=b.find(".mejs-time-current"),j=b.find(".mejs-time-handle"),m=b.find(".mejs-time-float"),q=b.find(".mejs-time-float-current"),p=function(h){h=h.pageX;var l=g.offset(),r=g.outerWidth(true),n=0,o=n=0;if(e.duration){if(h<l.left)h=l.left;else if(h>r+l.left)h=r+l.left;o=h-l.left;n=o/r;n=n<=0.02?0:n*e.duration;t&&n!==e.currentTime&&e.setCurrentTime(n);if(!mejs.MediaFeatures.hasTouch){m.css("left",o);q.html(mejs.Utility.secondsToTimeCode(n)); |
||||
m.show()}}},t=false;g.bind("mousedown",function(h){if(h.which===1){t=true;p(h);d.globalBind("mousemove.dur",function(l){p(l)});d.globalBind("mouseup.dur",function(){t=false;m.hide();d.globalUnbind(".dur")});return false}}).bind("mouseenter",function(){d.globalBind("mousemove.dur",function(h){p(h)});mejs.MediaFeatures.hasTouch||m.show()}).bind("mouseleave",function(){if(!t){d.globalUnbind(".dur");m.hide()}});e.addEventListener("progress",function(h){a.setProgressRail(h);a.setCurrentRail(h)},false); |
||||
e.addEventListener("timeupdate",function(h){a.setProgressRail(h);a.setCurrentRail(h)},false);d.loaded=c;d.total=g;d.current=k;d.handle=j},setProgressRail:function(a){var b=a!=undefined?a.target:this.media,c=null;if(b&&b.buffered&&b.buffered.length>0&&b.buffered.end&&b.duration)c=b.buffered.end(0)/b.duration;else if(b&&b.bytesTotal!=undefined&&b.bytesTotal>0&&b.bufferedBytes!=undefined)c=b.bufferedBytes/b.bytesTotal;else if(a&&a.lengthComputable&&a.total!=0)c=a.loaded/a.total;if(c!==null){c=Math.min(1, |
||||
Math.max(0,c));this.loaded&&this.total&&this.loaded.width(this.total.width()*c)}},setCurrentRail:function(){if(this.media.currentTime!=undefined&&this.media.duration)if(this.total&&this.handle){var a=Math.round(this.total.width()*this.media.currentTime/this.media.duration),b=a-Math.round(this.handle.outerWidth(true)/2);this.current.width(a);this.handle.css("left",b)}}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{duration:-1,timeAndDurationSeparator:"<span> | </span>"});f.extend(MediaElementPlayer.prototype,{buildcurrent:function(a,b,c,e){f('<div class="mejs-time"><span class="mejs-currenttime">'+(a.options.alwaysShowHours?"00:":"")+(a.options.showTimecodeFrameCount?"00:00:00":"00:00")+"</span></div>").appendTo(b);this.currenttime=this.controls.find(".mejs-currenttime");e.addEventListener("timeupdate",function(){a.updateCurrent()},false)},buildduration:function(a,b, |
||||
c,e){if(b.children().last().find(".mejs-currenttime").length>0)f(this.options.timeAndDurationSeparator+'<span class="mejs-duration">'+(this.options.duration>0?mejs.Utility.secondsToTimeCode(this.options.duration,this.options.alwaysShowHours||this.media.duration>3600,this.options.showTimecodeFrameCount,this.options.framesPerSecond||25):(a.options.alwaysShowHours?"00:":"")+(a.options.showTimecodeFrameCount?"00:00:00":"00:00"))+"</span>").appendTo(b.find(".mejs-time"));else{b.find(".mejs-currenttime").parent().addClass("mejs-currenttime-container"); |
||||
f('<div class="mejs-time mejs-duration-container"><span class="mejs-duration">'+(this.options.duration>0?mejs.Utility.secondsToTimeCode(this.options.duration,this.options.alwaysShowHours||this.media.duration>3600,this.options.showTimecodeFrameCount,this.options.framesPerSecond||25):(a.options.alwaysShowHours?"00:":"")+(a.options.showTimecodeFrameCount?"00:00:00":"00:00"))+"</span></div>").appendTo(b)}this.durationD=this.controls.find(".mejs-duration");e.addEventListener("timeupdate",function(){a.updateDuration()}, |
||||
false)},updateCurrent:function(){if(this.currenttime)this.currenttime.html(mejs.Utility.secondsToTimeCode(this.media.currentTime,this.options.alwaysShowHours||this.media.duration>3600,this.options.showTimecodeFrameCount,this.options.framesPerSecond||25))},updateDuration:function(){this.container.toggleClass("mejs-long-video",this.media.duration>3600);if(this.durationD&&(this.options.duration>0||this.media.duration))this.durationD.html(mejs.Utility.secondsToTimeCode(this.options.duration>0?this.options.duration: |
||||
this.media.duration,this.options.alwaysShowHours,this.options.showTimecodeFrameCount,this.options.framesPerSecond||25))}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{muteText:mejs.i18n.t("Mute Toggle"),hideVolumeOnTouchDevices:true,audioVolume:"horizontal",videoVolume:"vertical"});f.extend(MediaElementPlayer.prototype,{buildvolume:function(a,b,c,e){if(!(mejs.MediaFeatures.hasTouch&&this.options.hideVolumeOnTouchDevices)){var d=this,g=d.isVideo?d.options.videoVolume:d.options.audioVolume,k=g=="horizontal"?f('<div class="mejs-button mejs-volume-button mejs-mute"><button type="button" aria-controls="'+d.id+'" title="'+d.options.muteText+ |
||||
'" aria-label="'+d.options.muteText+'"></button></div><div class="mejs-horizontal-volume-slider"><div class="mejs-horizontal-volume-total"></div><div class="mejs-horizontal-volume-current"></div><div class="mejs-horizontal-volume-handle"></div></div>').appendTo(b):f('<div class="mejs-button mejs-volume-button mejs-mute"><button type="button" aria-controls="'+d.id+'" title="'+d.options.muteText+'" aria-label="'+d.options.muteText+'"></button><div class="mejs-volume-slider"><div class="mejs-volume-total"></div><div class="mejs-volume-current"></div><div class="mejs-volume-handle"></div></div></div>').appendTo(b), |
||||
j=d.container.find(".mejs-volume-slider, .mejs-horizontal-volume-slider"),m=d.container.find(".mejs-volume-total, .mejs-horizontal-volume-total"),q=d.container.find(".mejs-volume-current, .mejs-horizontal-volume-current"),p=d.container.find(".mejs-volume-handle, .mejs-horizontal-volume-handle"),t=function(n,o){if(!j.is(":visible")&&typeof o=="undefined"){j.show();t(n,true);j.hide()}else{n=Math.max(0,n);n=Math.min(n,1);n==0?k.removeClass("mejs-mute").addClass("mejs-unmute"):k.removeClass("mejs-unmute").addClass("mejs-mute"); |
||||
if(g=="vertical"){var s=m.height(),u=m.position(),v=s-s*n;p.css("top",Math.round(u.top+v-p.height()/2));q.height(s-v);q.css("top",u.top+v)}else{s=m.width();u=m.position();s=s*n;p.css("left",Math.round(u.left+s-p.width()/2));q.width(Math.round(s))}}},h=function(n){var o=null,s=m.offset();if(g=="vertical"){o=m.height();parseInt(m.css("top").replace(/px/,""),10);o=(o-(n.pageY-s.top))/o;if(s.top==0||s.left==0)return}else{o=m.width();o=(n.pageX-s.left)/o}o=Math.max(0,o);o=Math.min(o,1);t(o);o==0?e.setMuted(true): |
||||
e.setMuted(false);e.setVolume(o)},l=false,r=false;k.hover(function(){j.show();r=true},function(){r=false;!l&&g=="vertical"&&j.hide()});j.bind("mouseover",function(){r=true}).bind("mousedown",function(n){h(n);d.globalBind("mousemove.vol",function(o){h(o)});d.globalBind("mouseup.vol",function(){l=false;d.globalUnbind(".vol");!r&&g=="vertical"&&j.hide()});l=true;return false});k.find("button").click(function(){e.setMuted(!e.muted)});e.addEventListener("volumechange",function(){if(!l)if(e.muted){t(0); |
||||
k.removeClass("mejs-mute").addClass("mejs-unmute")}else{t(e.volume);k.removeClass("mejs-unmute").addClass("mejs-mute")}},false);if(d.container.is(":visible")){t(a.options.startVolume);a.options.startVolume===0&&e.setMuted(true);e.pluginType==="native"&&e.setVolume(a.options.startVolume)}}}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{usePluginFullScreen:true,newWindowCallback:function(){return""},fullscreenText:mejs.i18n.t("Fullscreen")});f.extend(MediaElementPlayer.prototype,{isFullScreen:false,isNativeFullScreen:false,isInIframe:false,buildfullscreen:function(a,b,c,e){if(a.isVideo){a.isInIframe=window.location!=window.parent.location;if(mejs.MediaFeatures.hasTrueNativeFullScreen){c=function(){if(a.isFullScreen)if(mejs.MediaFeatures.isFullScreen()){a.isNativeFullScreen=true;a.setControlsSize()}else{a.isNativeFullScreen= |
||||
false;a.exitFullScreen()}};mejs.MediaFeatures.hasMozNativeFullScreen?a.globalBind(mejs.MediaFeatures.fullScreenEventName,c):a.container.bind(mejs.MediaFeatures.fullScreenEventName,c)}var d=this,g=f('<div class="mejs-button mejs-fullscreen-button"><button type="button" aria-controls="'+d.id+'" title="'+d.options.fullscreenText+'" aria-label="'+d.options.fullscreenText+'"></button></div>').appendTo(b);if(d.media.pluginType==="native"||!d.options.usePluginFullScreen&&!mejs.MediaFeatures.isFirefox)g.click(function(){mejs.MediaFeatures.hasTrueNativeFullScreen&& |
||||
mejs.MediaFeatures.isFullScreen()||a.isFullScreen?a.exitFullScreen():a.enterFullScreen()});else{var k=null;if(function(){var h=document.createElement("x"),l=document.documentElement,r=window.getComputedStyle;if(!("pointerEvents"in h.style))return false;h.style.pointerEvents="auto";h.style.pointerEvents="x";l.appendChild(h);r=r&&r(h,"").pointerEvents==="auto";l.removeChild(h);return!!r}()&&!mejs.MediaFeatures.isOpera){var j=false,m=function(){if(j){for(var h in q)q[h].hide();g.css("pointer-events", |
||||
"");d.controls.css("pointer-events","");d.media.removeEventListener("click",d.clickToPlayPauseCallback);j=false}},q={};b=["top","left","right","bottom"];var p,t=function(){var h=g.offset().left-d.container.offset().left,l=g.offset().top-d.container.offset().top,r=g.outerWidth(true),n=g.outerHeight(true),o=d.container.width(),s=d.container.height();for(p in q)q[p].css({position:"absolute",top:0,left:0});q.top.width(o).height(l);q.left.width(h).height(n).css({top:l});q.right.width(o-h-r).height(n).css({top:l, |
||||
left:h+r});q.bottom.width(o).height(s-n-l).css({top:l+n})};d.globalBind("resize",function(){t()});p=0;for(c=b.length;p<c;p++)q[b[p]]=f('<div class="mejs-fullscreen-hover" />').appendTo(d.container).mouseover(m).hide();g.on("mouseover",function(){if(!d.isFullScreen){var h=g.offset(),l=a.container.offset();e.positionFullscreenButton(h.left-l.left,h.top-l.top,false);g.css("pointer-events","none");d.controls.css("pointer-events","none");d.media.addEventListener("click",d.clickToPlayPauseCallback);for(p in q)q[p].show(); |
||||
t();j=true}});e.addEventListener("fullscreenchange",function(){d.isFullScreen=!d.isFullScreen;d.isFullScreen?d.media.removeEventListener("click",d.clickToPlayPauseCallback):d.media.addEventListener("click",d.clickToPlayPauseCallback);m()});d.globalBind("mousemove",function(h){if(j){var l=g.offset();if(h.pageY<l.top||h.pageY>l.top+g.outerHeight(true)||h.pageX<l.left||h.pageX>l.left+g.outerWidth(true)){g.css("pointer-events","");d.controls.css("pointer-events","");j=false}}})}else g.on("mouseover", |
||||
function(){if(k!==null){clearTimeout(k);delete k}var h=g.offset(),l=a.container.offset();e.positionFullscreenButton(h.left-l.left,h.top-l.top,true)}).on("mouseout",function(){if(k!==null){clearTimeout(k);delete k}k=setTimeout(function(){e.hideFullscreenButton()},1500)})}a.fullscreenBtn=g;d.globalBind("keydown",function(h){if((mejs.MediaFeatures.hasTrueNativeFullScreen&&mejs.MediaFeatures.isFullScreen()||d.isFullScreen)&&h.keyCode==27)a.exitFullScreen()})}},cleanfullscreen:function(a){a.exitFullScreen()}, |
||||
containerSizeTimeout:null,enterFullScreen:function(){var a=this;if(!(a.media.pluginType!=="native"&&(mejs.MediaFeatures.isFirefox||a.options.usePluginFullScreen))){f(document.documentElement).addClass("mejs-fullscreen");normalHeight=a.container.height();normalWidth=a.container.width();if(a.media.pluginType==="native")if(mejs.MediaFeatures.hasTrueNativeFullScreen){mejs.MediaFeatures.requestFullScreen(a.container[0]);a.isInIframe&&setTimeout(function c(){if(a.isNativeFullScreen)f(window).width()!== |
||||
screen.width?a.exitFullScreen():setTimeout(c,500)},500)}else if(mejs.MediaFeatures.hasSemiNativeFullScreen){a.media.webkitEnterFullscreen();return}if(a.isInIframe){var b=a.options.newWindowCallback(this);if(b!=="")if(mejs.MediaFeatures.hasTrueNativeFullScreen)setTimeout(function(){if(!a.isNativeFullScreen){a.pause();window.open(b,a.id,"top=0,left=0,width="+screen.availWidth+",height="+screen.availHeight+",resizable=yes,scrollbars=no,status=no,toolbar=no")}},250);else{a.pause();window.open(b,a.id, |
||||
"top=0,left=0,width="+screen.availWidth+",height="+screen.availHeight+",resizable=yes,scrollbars=no,status=no,toolbar=no");return}}a.container.addClass("mejs-container-fullscreen").width("100%").height("100%");a.containerSizeTimeout=setTimeout(function(){a.container.css({width:"100%",height:"100%"});a.setControlsSize()},500);if(a.media.pluginType==="native")a.$media.width("100%").height("100%");else{a.container.find(".mejs-shim").width("100%").height("100%");a.media.setVideoSize(f(window).width(), |
||||
f(window).height())}a.layers.children("div").width("100%").height("100%");a.fullscreenBtn&&a.fullscreenBtn.removeClass("mejs-fullscreen").addClass("mejs-unfullscreen");a.setControlsSize();a.isFullScreen=true}},exitFullScreen:function(){clearTimeout(this.containerSizeTimeout);if(this.media.pluginType!=="native"&&mejs.MediaFeatures.isFirefox)this.media.setFullscreen(false);else{if(mejs.MediaFeatures.hasTrueNativeFullScreen&&(mejs.MediaFeatures.isFullScreen()||this.isFullScreen))mejs.MediaFeatures.cancelFullScreen(); |
||||
f(document.documentElement).removeClass("mejs-fullscreen");this.container.removeClass("mejs-container-fullscreen").width(normalWidth).height(normalHeight);if(this.media.pluginType==="native")this.$media.width(normalWidth).height(normalHeight);else{this.container.find(".mejs-shim").width(normalWidth).height(normalHeight);this.media.setVideoSize(normalWidth,normalHeight)}this.layers.children("div").width(normalWidth).height(normalHeight);this.fullscreenBtn.removeClass("mejs-unfullscreen").addClass("mejs-fullscreen"); |
||||
this.setControlsSize();this.isFullScreen=false}}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{startLanguage:"",tracksText:mejs.i18n.t("Captions/Subtitles"),hideCaptionsButtonWhenEmpty:true,toggleCaptionsButtonWhenOnlyOne:false,slidesSelector:""});f.extend(MediaElementPlayer.prototype,{hasChapters:false,buildtracks:function(a,b,c,e){if(a.tracks.length!=0){var d;if(this.domNode.textTracks)for(d=this.domNode.textTracks.length-1;d>=0;d--)this.domNode.textTracks[d].mode="hidden";a.chapters=f('<div class="mejs-chapters mejs-layer"></div>').prependTo(c).hide();a.captions= |
||||
f('<div class="mejs-captions-layer mejs-layer"><div class="mejs-captions-position mejs-captions-position-hover"><span class="mejs-captions-text"></span></div></div>').prependTo(c).hide();a.captionsText=a.captions.find(".mejs-captions-text");a.captionsButton=f('<div class="mejs-button mejs-captions-button"><button type="button" aria-controls="'+this.id+'" title="'+this.options.tracksText+'" aria-label="'+this.options.tracksText+'"></button><div class="mejs-captions-selector"><ul><li><input type="radio" name="'+ |
||||
a.id+'_captions" id="'+a.id+'_captions_none" value="none" checked="checked" /><label for="'+a.id+'_captions_none">'+mejs.i18n.t("None")+"</label></li></ul></div></div>").appendTo(b);for(d=b=0;d<a.tracks.length;d++)a.tracks[d].kind=="subtitles"&&b++;this.options.toggleCaptionsButtonWhenOnlyOne&&b==1?a.captionsButton.on("click",function(){a.setTrack(a.selectedTrack==null?a.tracks[0].srclang:"none")}):a.captionsButton.hover(function(){f(this).find(".mejs-captions-selector").css("visibility","visible")}, |
||||
function(){f(this).find(".mejs-captions-selector").css("visibility","hidden")}).on("click","input[type=radio]",function(){lang=this.value;a.setTrack(lang)});a.options.alwaysShowControls?a.container.find(".mejs-captions-position").addClass("mejs-captions-position-hover"):a.container.bind("controlsshown",function(){a.container.find(".mejs-captions-position").addClass("mejs-captions-position-hover")}).bind("controlshidden",function(){e.paused||a.container.find(".mejs-captions-position").removeClass("mejs-captions-position-hover")}); |
||||
a.trackToLoad=-1;a.selectedTrack=null;a.isLoadingTrack=false;for(d=0;d<a.tracks.length;d++)a.tracks[d].kind=="subtitles"&&a.addTrackButton(a.tracks[d].srclang,a.tracks[d].label);a.loadNextTrack();e.addEventListener("timeupdate",function(){a.displayCaptions()},false);if(a.options.slidesSelector!=""){a.slidesContainer=f(a.options.slidesSelector);e.addEventListener("timeupdate",function(){a.displaySlides()},false)}e.addEventListener("loadedmetadata",function(){a.displayChapters()},false);a.container.hover(function(){if(a.hasChapters){a.chapters.css("visibility", |
||||
"visible");a.chapters.fadeIn(200).height(a.chapters.find(".mejs-chapter").outerHeight())}},function(){a.hasChapters&&!e.paused&&a.chapters.fadeOut(200,function(){f(this).css("visibility","hidden");f(this).css("display","block")})});a.node.getAttribute("autoplay")!==null&&a.chapters.css("visibility","hidden")}},setTrack:function(a){var b;if(a=="none"){this.selectedTrack=null;this.captionsButton.removeClass("mejs-captions-enabled")}else for(b=0;b<this.tracks.length;b++)if(this.tracks[b].srclang==a){this.selectedTrack== |
||||
null&&this.captionsButton.addClass("mejs-captions-enabled");this.selectedTrack=this.tracks[b];this.captions.attr("lang",this.selectedTrack.srclang);this.displayCaptions();break}},loadNextTrack:function(){this.trackToLoad++;if(this.trackToLoad<this.tracks.length){this.isLoadingTrack=true;this.loadTrack(this.trackToLoad)}else{this.isLoadingTrack=false;this.checkForTracks()}},loadTrack:function(a){var b=this,c=b.tracks[a];f.ajax({url:c.src,dataType:"text",success:function(e){c.entries=typeof e=="string"&& |
||||
/<tt\s+xml/ig.exec(e)?mejs.TrackFormatParser.dfxp.parse(e):mejs.TrackFormatParser.webvvt.parse(e);c.isLoaded=true;b.enableTrackButton(c.srclang,c.label);b.loadNextTrack();c.kind=="chapters"&&b.media.addEventListener("play",function(){b.media.duration>0&&b.displayChapters(c)},false);c.kind=="slides"&&b.setupSlides(c)},error:function(){b.loadNextTrack()}})},enableTrackButton:function(a,b){if(b==="")b=mejs.language.codes[a]||a;this.captionsButton.find("input[value="+a+"]").prop("disabled",false).siblings("label").html(b); |
||||
this.options.startLanguage==a&&f("#"+this.id+"_captions_"+a).click();this.adjustLanguageBox()},addTrackButton:function(a,b){if(b==="")b=mejs.language.codes[a]||a;this.captionsButton.find("ul").append(f('<li><input type="radio" name="'+this.id+'_captions" id="'+this.id+"_captions_"+a+'" value="'+a+'" disabled="disabled" /><label for="'+this.id+"_captions_"+a+'">'+b+" (loading)</label></li>"));this.adjustLanguageBox();this.container.find(".mejs-captions-translations option[value="+a+"]").remove()}, |
||||
adjustLanguageBox:function(){this.captionsButton.find(".mejs-captions-selector").height(this.captionsButton.find(".mejs-captions-selector ul").outerHeight(true)+this.captionsButton.find(".mejs-captions-translations").outerHeight(true))},checkForTracks:function(){var a=false;if(this.options.hideCaptionsButtonWhenEmpty){for(i=0;i<this.tracks.length;i++)if(this.tracks[i].kind=="subtitles"){a=true;break}if(!a){this.captionsButton.hide();this.setControlsSize()}}},displayCaptions:function(){if(typeof this.tracks!= |
||||
"undefined"){var a,b=this.selectedTrack;if(b!=null&&b.isLoaded)for(a=0;a<b.entries.times.length;a++)if(this.media.currentTime>=b.entries.times[a].start&&this.media.currentTime<=b.entries.times[a].stop){this.captionsText.html(b.entries.text[a]);this.captions.show().height(0);return}this.captions.hide()}},setupSlides:function(a){this.slides=a;this.slides.entries.imgs=[this.slides.entries.text.length];this.showSlide(0)},showSlide:function(a){if(!(typeof this.tracks=="undefined"||typeof this.slidesContainer== |
||||
"undefined")){var b=this,c=b.slides.entries.text[a],e=b.slides.entries.imgs[a];if(typeof e=="undefined"||typeof e.fadeIn=="undefined")b.slides.entries.imgs[a]=e=f('<img src="'+c+'">').on("load",function(){e.appendTo(b.slidesContainer).hide().fadeIn().siblings(":visible").fadeOut()});else!e.is(":visible")&&!e.is(":animated")&&e.fadeIn().siblings(":visible").fadeOut()}},displaySlides:function(){if(typeof this.slides!="undefined"){var a=this.slides,b;for(b=0;b<a.entries.times.length;b++)if(this.media.currentTime>= |
||||
a.entries.times[b].start&&this.media.currentTime<=a.entries.times[b].stop){this.showSlide(b);break}}},displayChapters:function(){var a;for(a=0;a<this.tracks.length;a++)if(this.tracks[a].kind=="chapters"&&this.tracks[a].isLoaded){this.drawChapters(this.tracks[a]);this.hasChapters=true;break}},drawChapters:function(a){var b=this,c,e,d=e=0;b.chapters.empty();for(c=0;c<a.entries.times.length;c++){e=a.entries.times[c].stop-a.entries.times[c].start;e=Math.floor(e/b.media.duration*100);if(e+d>100||c==a.entries.times.length- |
||||
1&&e+d<100)e=100-d;b.chapters.append(f('<div class="mejs-chapter" rel="'+a.entries.times[c].start+'" style="left: '+d.toString()+"%;width: "+e.toString()+'%;"><div class="mejs-chapter-block'+(c==a.entries.times.length-1?" mejs-chapter-block-last":"")+'"><span class="ch-title">'+a.entries.text[c]+'</span><span class="ch-time">'+mejs.Utility.secondsToTimeCode(a.entries.times[c].start)+"–"+mejs.Utility.secondsToTimeCode(a.entries.times[c].stop)+"</span></div></div>"));d+=e}b.chapters.find("div.mejs-chapter").click(function(){b.media.setCurrentTime(parseFloat(f(this).attr("rel"))); |
||||
b.media.paused&&b.media.play()});b.chapters.show()}});mejs.language={codes:{af:"Afrikaans",sq:"Albanian",ar:"Arabic",be:"Belarusian",bg:"Bulgarian",ca:"Catalan",zh:"Chinese","zh-cn":"Chinese Simplified","zh-tw":"Chinese Traditional",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch",en:"English",et:"Estonian",tl:"Filipino",fi:"Finnish",fr:"French",gl:"Galician",de:"German",el:"Greek",ht:"Haitian Creole",iw:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",ga:"Irish",it:"Italian",ja:"Japanese", |
||||
ko:"Korean",lv:"Latvian",lt:"Lithuanian",mk:"Macedonian",ms:"Malay",mt:"Maltese",no:"Norwegian",fa:"Persian",pl:"Polish",pt:"Portuguese",ro:"Romanian",ru:"Russian",sr:"Serbian",sk:"Slovak",sl:"Slovenian",es:"Spanish",sw:"Swahili",sv:"Swedish",tl:"Tagalog",th:"Thai",tr:"Turkish",uk:"Ukrainian",vi:"Vietnamese",cy:"Welsh",yi:"Yiddish"}};mejs.TrackFormatParser={webvvt:{pattern_identifier:/^([a-zA-z]+-)?[0-9]+$/,pattern_timecode:/^([0-9]{2}:[0-9]{2}:[0-9]{2}([,.][0-9]{1,3})?) --\> ([0-9]{2}:[0-9]{2}:[0-9]{2}([,.][0-9]{3})?)(.*)$/, |
||||
parse:function(a){var b=0;a=mejs.TrackFormatParser.split2(a,/\r?\n/);for(var c={text:[],times:[]},e,d;b<a.length;b++)if(this.pattern_identifier.exec(a[b])){b++;if((e=this.pattern_timecode.exec(a[b]))&&b<a.length){b++;d=a[b];for(b++;a[b]!==""&&b<a.length;){d=d+"\n"+a[b];b++}d=f.trim(d).replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig,"<a href='$1' target='_blank'>$1</a>");c.text.push(d);c.times.push({start:mejs.Utility.convertSMPTEtoSeconds(e[1])==0?0.2:mejs.Utility.convertSMPTEtoSeconds(e[1]), |
||||
stop:mejs.Utility.convertSMPTEtoSeconds(e[3]),settings:e[5]})}}return c}},dfxp:{parse:function(a){a=f(a).filter("tt");var b=0;b=a.children("div").eq(0);var c=b.find("p");b=a.find("#"+b.attr("style"));var e,d;a={text:[],times:[]};if(b.length){d=b.removeAttr("id").get(0).attributes;if(d.length){e={};for(b=0;b<d.length;b++)e[d[b].name.split(":")[1]]=d[b].value}}for(b=0;b<c.length;b++){var g;d={start:null,stop:null,style:null};if(c.eq(b).attr("begin"))d.start=mejs.Utility.convertSMPTEtoSeconds(c.eq(b).attr("begin")); |
||||
if(!d.start&&c.eq(b-1).attr("end"))d.start=mejs.Utility.convertSMPTEtoSeconds(c.eq(b-1).attr("end"));if(c.eq(b).attr("end"))d.stop=mejs.Utility.convertSMPTEtoSeconds(c.eq(b).attr("end"));if(!d.stop&&c.eq(b+1).attr("begin"))d.stop=mejs.Utility.convertSMPTEtoSeconds(c.eq(b+1).attr("begin"));if(e){g="";for(var k in e)g+=k+":"+e[k]+";"}if(g)d.style=g;if(d.start==0)d.start=0.2;a.times.push(d);d=f.trim(c.eq(b).html()).replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, |
||||
"<a href='$1' target='_blank'>$1</a>");a.text.push(d);if(a.times.start==0)a.times.start=2}return a}},split2:function(a,b){return a.split(b)}};if("x\n\ny".split(/\n/gi).length!=3)mejs.TrackFormatParser.split2=function(a,b){var c=[],e="",d;for(d=0;d<a.length;d++){e+=a.substring(d,d+1);if(b.test(e)){c.push(e.replace(b,""));e=""}}c.push(e);return c}})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{contextMenuItems:[{render:function(a){if(typeof a.enterFullScreen=="undefined")return null;return a.isFullScreen?mejs.i18n.t("Turn off Fullscreen"):mejs.i18n.t("Go Fullscreen")},click:function(a){a.isFullScreen?a.exitFullScreen():a.enterFullScreen()}},{render:function(a){return a.media.muted?mejs.i18n.t("Unmute"):mejs.i18n.t("Mute")},click:function(a){a.media.muted?a.setMuted(false):a.setMuted(true)}},{isSeparator:true},{render:function(){return mejs.i18n.t("Download Video")}, |
||||
click:function(a){window.location.href=a.media.currentSrc}}]});f.extend(MediaElementPlayer.prototype,{buildcontextmenu:function(a){a.contextMenu=f('<div class="mejs-contextmenu"></div>').appendTo(f("body")).hide();a.container.bind("contextmenu",function(b){if(a.isContextMenuEnabled){b.preventDefault();a.renderContextMenu(b.clientX-1,b.clientY-1);return false}});a.container.bind("click",function(){a.contextMenu.hide()});a.contextMenu.bind("mouseleave",function(){a.startContextMenuTimer()})},cleancontextmenu:function(a){a.contextMenu.remove()}, |
||||
isContextMenuEnabled:true,enableContextMenu:function(){this.isContextMenuEnabled=true},disableContextMenu:function(){this.isContextMenuEnabled=false},contextMenuTimeout:null,startContextMenuTimer:function(){var a=this;a.killContextMenuTimer();a.contextMenuTimer=setTimeout(function(){a.hideContextMenu();a.killContextMenuTimer()},750)},killContextMenuTimer:function(){var a=this.contextMenuTimer;if(a!=null){clearTimeout(a);delete a}},hideContextMenu:function(){this.contextMenu.hide()},renderContextMenu:function(a, |
||||
b){for(var c=this,e="",d=c.options.contextMenuItems,g=0,k=d.length;g<k;g++)if(d[g].isSeparator)e+='<div class="mejs-contextmenu-separator"></div>';else{var j=d[g].render(c);if(j!=null)e+='<div class="mejs-contextmenu-item" data-itemindex="'+g+'" id="element-'+Math.random()*1E6+'">'+j+"</div>"}c.contextMenu.empty().append(f(e)).css({top:b,left:a}).show();c.contextMenu.find(".mejs-contextmenu-item").each(function(){var m=f(this),q=parseInt(m.data("itemindex"),10),p=c.options.contextMenuItems[q];typeof p.show!= |
||||
"undefined"&&p.show(m,c);m.click(function(){typeof p.click!="undefined"&&p.click(c);c.contextMenu.hide()})});setTimeout(function(){c.killControlsTimer("rev3")},100)}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{postrollCloseText:mejs.i18n.t("Close")});f.extend(MediaElementPlayer.prototype,{buildpostroll:function(a,b,c){var e=this.container.find('link[rel="postroll"]').attr("href");if(typeof e!=="undefined"){a.postroll=f('<div class="mejs-postroll-layer mejs-layer"><a class="mejs-postroll-close" onclick="$(this).parent().hide();return false;">'+this.options.postrollCloseText+'</a><div class="mejs-postroll-layer-content"></div></div>').prependTo(c).hide();this.media.addEventListener("ended", |
||||
function(){f.ajax({dataType:"html",url:e,success:function(d){c.find(".mejs-postroll-layer-content").html(d)}});a.postroll.show()},false)}}})})(mejs.$); |
||||
|
||||
@ -0,0 +1,68 @@ |
||||
/*! |
||||
* MediaElement.js |
||||
* HTML5 <video> and <audio> shim and player |
||||
* http://mediaelementjs.com/
|
||||
* |
||||
* Creates a JavaScript object that mimics HTML5 MediaElement API |
||||
* for browsers that don't understand HTML5 or can't play the provided codec |
||||
* Can play MP4 (H.264), Ogg, WebM, FLV, WMV, WMA, ACC, and MP3 |
||||
* |
||||
* Copyright 2010-2013, John Dyer (http://j.hn)
|
||||
* License: MIT |
||||
* |
||||
*/var mejs=mejs||{};mejs.version="2.13.0";mejs.meIndex=0; |
||||
mejs.plugins={silverlight:[{version:[3,0],types:["video/mp4","video/m4v","video/mov","video/wmv","audio/wma","audio/m4a","audio/mp3","audio/wav","audio/mpeg"]}],flash:[{version:[9,0,124],types:["video/mp4","video/m4v","video/mov","video/flv","video/rtmp","video/x-flv","audio/flv","audio/x-flv","audio/mp3","audio/m4a","audio/mpeg","video/youtube","video/x-youtube"]}],youtube:[{version:null,types:["video/youtube","video/x-youtube","audio/youtube","audio/x-youtube"]}],vimeo:[{version:null,types:["video/vimeo", |
||||
"video/x-vimeo"]}]}; |
||||
mejs.Utility={encodeUrl:function(a){return encodeURIComponent(a)},escapeHTML:function(a){return a.toString().split("&").join("&").split("<").join("<").split('"').join(""")},absolutizeUrl:function(a){var b=document.createElement("div");b.innerHTML='<a href="'+this.escapeHTML(a)+'">x</a>';return b.firstChild.href},getScriptPath:function(a){for(var b=0,c,d="",e="",f,g,h=document.getElementsByTagName("script"),l=h.length,j=a.length;b<l;b++){f=h[b].src;c=f.lastIndexOf("/");if(c>-1){g=f.substring(c+ |
||||
1);f=f.substring(0,c+1)}else{g=f;f=""}for(c=0;c<j;c++){e=a[c];e=g.indexOf(e);if(e>-1){d=f;break}}if(d!=="")break}return d},secondsToTimeCode:function(a,b,c,d){if(typeof c=="undefined")c=false;else if(typeof d=="undefined")d=25;var e=Math.floor(a/3600)%24,f=Math.floor(a/60)%60,g=Math.floor(a%60);a=Math.floor((a%1*d).toFixed(3));return(b||e>0?(e<10?"0"+e:e)+":":"")+(f<10?"0"+f:f)+":"+(g<10?"0"+g:g)+(c?":"+(a<10?"0"+a:a):"")},timeCodeToSeconds:function(a,b,c,d){if(typeof c=="undefined")c=false;else if(typeof d== |
||||
"undefined")d=25;a=a.split(":");b=parseInt(a[0],10);var e=parseInt(a[1],10),f=parseInt(a[2],10),g=0,h=0;if(c)g=parseInt(a[3])/d;return h=b*3600+e*60+f+g},convertSMPTEtoSeconds:function(a){if(typeof a!="string")return false;a=a.replace(",",".");var b=0,c=a.indexOf(".")!=-1?a.split(".")[1].length:0,d=1;a=a.split(":").reverse();for(var e=0;e<a.length;e++){d=1;if(e>0)d=Math.pow(60,e);b+=Number(a[e])*d}return Number(b.toFixed(c))},removeSwf:function(a){var b=document.getElementById(a);if(b&&/object|embed/i.test(b.nodeName))if(mejs.MediaFeatures.isIE){b.style.display= |
||||
"none";(function(){b.readyState==4?mejs.Utility.removeObjectInIE(a):setTimeout(arguments.callee,10)})()}else b.parentNode.removeChild(b)},removeObjectInIE:function(a){if(a=document.getElementById(a)){for(var b in a)if(typeof a[b]=="function")a[b]=null;a.parentNode.removeChild(a)}}}; |
||||
mejs.PluginDetector={hasPluginVersion:function(a,b){var c=this.plugins[a];b[1]=b[1]||0;b[2]=b[2]||0;return c[0]>b[0]||c[0]==b[0]&&c[1]>b[1]||c[0]==b[0]&&c[1]==b[1]&&c[2]>=b[2]?true:false},nav:window.navigator,ua:window.navigator.userAgent.toLowerCase(),plugins:[],addPlugin:function(a,b,c,d,e){this.plugins[a]=this.detectPlugin(b,c,d,e)},detectPlugin:function(a,b,c,d){var e=[0,0,0],f;if(typeof this.nav.plugins!="undefined"&&typeof this.nav.plugins[a]=="object"){if((c=this.nav.plugins[a].description)&& |
||||
!(typeof this.nav.mimeTypes!="undefined"&&this.nav.mimeTypes[b]&&!this.nav.mimeTypes[b].enabledPlugin)){e=c.replace(a,"").replace(/^\s+/,"").replace(/\sr/gi,".").split(".");for(a=0;a<e.length;a++)e[a]=parseInt(e[a].match(/\d+/),10)}}else if(typeof window.ActiveXObject!="undefined")try{if(f=new ActiveXObject(c))e=d(f)}catch(g){}return e}}; |
||||
mejs.PluginDetector.addPlugin("flash","Shockwave Flash","application/x-shockwave-flash","ShockwaveFlash.ShockwaveFlash",function(a){var b=[];if(a=a.GetVariable("$version")){a=a.split(" ")[1].split(",");b=[parseInt(a[0],10),parseInt(a[1],10),parseInt(a[2],10)]}return b}); |
||||
mejs.PluginDetector.addPlugin("silverlight","Silverlight Plug-In","application/x-silverlight-2","AgControl.AgControl",function(a){var b=[0,0,0,0],c=function(d,e,f,g){for(;d.isVersionSupported(e[0]+"."+e[1]+"."+e[2]+"."+e[3]);)e[f]+=g;e[f]-=g};c(a,b,0,1);c(a,b,1,1);c(a,b,2,1E4);c(a,b,2,1E3);c(a,b,2,100);c(a,b,2,10);c(a,b,2,1);c(a,b,3,1);return b}); |
||||
mejs.MediaFeatures={init:function(){var a=this,b=document,c=mejs.PluginDetector.nav,d=mejs.PluginDetector.ua.toLowerCase(),e,f=["source","track","audio","video"];a.isiPad=d.match(/ipad/i)!==null;a.isiPhone=d.match(/iphone/i)!==null;a.isiOS=a.isiPhone||a.isiPad;a.isAndroid=d.match(/android/i)!==null;a.isBustedAndroid=d.match(/android 2\.[12]/)!==null;a.isBustedNativeHTTPS=location.protocol==="https:"&&(d.match(/android [12]\./)!==null||d.match(/macintosh.* version.* safari/)!==null);a.isIE=c.appName.toLowerCase().indexOf("microsoft")!= |
||||
-1;a.isChrome=d.match(/chrome/gi)!==null;a.isFirefox=d.match(/firefox/gi)!==null;a.isWebkit=d.match(/webkit/gi)!==null;a.isGecko=d.match(/gecko/gi)!==null&&!a.isWebkit;a.isOpera=d.match(/opera/gi)!==null;a.hasTouch="ontouchstart"in window&&window.ontouchstart!=null;a.svg=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect;for(c=0;c<f.length;c++)e=document.createElement(f[c]);a.supportsMediaTag=typeof e.canPlayType!=="undefined"||a.isBustedAndroid; |
||||
try{e.canPlayType("video/mp4")}catch(g){a.supportsMediaTag=false}a.hasSemiNativeFullScreen=typeof e.webkitEnterFullscreen!=="undefined";a.hasWebkitNativeFullScreen=typeof e.webkitRequestFullScreen!=="undefined";a.hasMozNativeFullScreen=typeof e.mozRequestFullScreen!=="undefined";a.hasTrueNativeFullScreen=a.hasWebkitNativeFullScreen||a.hasMozNativeFullScreen;a.nativeFullScreenEnabled=a.hasTrueNativeFullScreen;if(a.hasMozNativeFullScreen)a.nativeFullScreenEnabled=e.mozFullScreenEnabled;if(this.isChrome)a.hasSemiNativeFullScreen= |
||||
false;if(a.hasTrueNativeFullScreen){a.fullScreenEventName=a.hasWebkitNativeFullScreen?"webkitfullscreenchange":"mozfullscreenchange";a.isFullScreen=function(){if(e.mozRequestFullScreen)return b.mozFullScreen;else if(e.webkitRequestFullScreen)return b.webkitIsFullScreen};a.requestFullScreen=function(h){if(a.hasWebkitNativeFullScreen)h.webkitRequestFullScreen();else a.hasMozNativeFullScreen&&h.mozRequestFullScreen()};a.cancelFullScreen=function(){if(a.hasWebkitNativeFullScreen)document.webkitCancelFullScreen(); |
||||
else a.hasMozNativeFullScreen&&document.mozCancelFullScreen()}}if(a.hasSemiNativeFullScreen&&d.match(/mac os x 10_5/i)){a.hasNativeFullScreen=false;a.hasSemiNativeFullScreen=false}}};mejs.MediaFeatures.init(); |
||||
mejs.HtmlMediaElement={pluginType:"native",isFullScreen:false,setCurrentTime:function(a){this.currentTime=a},setMuted:function(a){this.muted=a},setVolume:function(a){this.volume=a},stop:function(){this.pause()},setSrc:function(a){for(var b=this.getElementsByTagName("source");b.length>0;)this.removeChild(b[0]);if(typeof a=="string")this.src=a;else{var c;for(b=0;b<a.length;b++){c=a[b];if(this.canPlayType(c.type)){this.src=c.src;break}}}},setVideoSize:function(a,b){this.width=a;this.height=b}}; |
||||
mejs.PluginMediaElement=function(a,b,c){this.id=a;this.pluginType=b;this.src=c;this.events={};this.attributes={}}; |
||||
mejs.PluginMediaElement.prototype={pluginElement:null,pluginType:"",isFullScreen:false,playbackRate:-1,defaultPlaybackRate:-1,seekable:[],played:[],paused:true,ended:false,seeking:false,duration:0,error:null,tagName:"",muted:false,volume:1,currentTime:0,play:function(){if(this.pluginApi!=null){this.pluginType=="youtube"?this.pluginApi.playVideo():this.pluginApi.playMedia();this.paused=false}},load:function(){if(this.pluginApi!=null){this.pluginType!="youtube"&&this.pluginApi.loadMedia();this.paused= |
||||
false}},pause:function(){if(this.pluginApi!=null){this.pluginType=="youtube"?this.pluginApi.pauseVideo():this.pluginApi.pauseMedia();this.paused=true}},stop:function(){if(this.pluginApi!=null){this.pluginType=="youtube"?this.pluginApi.stopVideo():this.pluginApi.stopMedia();this.paused=true}},canPlayType:function(a){var b,c,d,e=mejs.plugins[this.pluginType];for(b=0;b<e.length;b++){d=e[b];if(mejs.PluginDetector.hasPluginVersion(this.pluginType,d.version))for(c=0;c<d.types.length;c++)if(a==d.types[c])return"probably"}return""}, |
||||
positionFullscreenButton:function(a,b,c){this.pluginApi!=null&&this.pluginApi.positionFullscreenButton&&this.pluginApi.positionFullscreenButton(Math.floor(a),Math.floor(b),c)},hideFullscreenButton:function(){this.pluginApi!=null&&this.pluginApi.hideFullscreenButton&&this.pluginApi.hideFullscreenButton()},setSrc:function(a){if(typeof a=="string"){this.pluginApi.setSrc(mejs.Utility.absolutizeUrl(a));this.src=mejs.Utility.absolutizeUrl(a)}else{var b,c;for(b=0;b<a.length;b++){c=a[b];if(this.canPlayType(c.type)){this.pluginApi.setSrc(mejs.Utility.absolutizeUrl(c.src)); |
||||
this.src=mejs.Utility.absolutizeUrl(a);break}}}},setCurrentTime:function(a){if(this.pluginApi!=null){this.pluginType=="youtube"?this.pluginApi.seekTo(a):this.pluginApi.setCurrentTime(a);this.currentTime=a}},setVolume:function(a){if(this.pluginApi!=null){this.pluginType=="youtube"?this.pluginApi.setVolume(a*100):this.pluginApi.setVolume(a);this.volume=a}},setMuted:function(a){if(this.pluginApi!=null){if(this.pluginType=="youtube"){a?this.pluginApi.mute():this.pluginApi.unMute();this.muted=a;this.dispatchEvent("volumechange")}else this.pluginApi.setMuted(a); |
||||
this.muted=a}},setVideoSize:function(a,b){if(this.pluginElement.style){this.pluginElement.style.width=a+"px";this.pluginElement.style.height=b+"px"}this.pluginApi!=null&&this.pluginApi.setVideoSize&&this.pluginApi.setVideoSize(a,b)},setFullscreen:function(a){this.pluginApi!=null&&this.pluginApi.setFullscreen&&this.pluginApi.setFullscreen(a)},enterFullScreen:function(){this.pluginApi!=null&&this.pluginApi.setFullscreen&&this.setFullscreen(true)},exitFullScreen:function(){this.pluginApi!=null&&this.pluginApi.setFullscreen&& |
||||
this.setFullscreen(false)},addEventListener:function(a,b){this.events[a]=this.events[a]||[];this.events[a].push(b)},removeEventListener:function(a,b){if(!a){this.events={};return true}var c=this.events[a];if(!c)return true;if(!b){this.events[a]=[];return true}for(i=0;i<c.length;i++)if(c[i]===b){this.events[a].splice(i,1);return true}return false},dispatchEvent:function(a){var b,c,d=this.events[a];if(d){c=Array.prototype.slice.call(arguments,1);for(b=0;b<d.length;b++)d[b].apply(null,c)}},hasAttribute:function(a){return a in |
||||
this.attributes},removeAttribute:function(a){delete this.attributes[a]},getAttribute:function(a){if(this.hasAttribute(a))return this.attributes[a];return""},setAttribute:function(a,b){this.attributes[a]=b},remove:function(){mejs.Utility.removeSwf(this.pluginElement.id);mejs.MediaPluginBridge.unregisterPluginElement(this.pluginElement.id)}}; |
||||
mejs.MediaPluginBridge={pluginMediaElements:{},htmlMediaElements:{},registerPluginElement:function(a,b,c){this.pluginMediaElements[a]=b;this.htmlMediaElements[a]=c},unregisterPluginElement:function(a){delete this.pluginMediaElements[a];delete this.htmlMediaElements[a]},initPlugin:function(a){var b=this.pluginMediaElements[a],c=this.htmlMediaElements[a];if(b){switch(b.pluginType){case "flash":b.pluginElement=b.pluginApi=document.getElementById(a);break;case "silverlight":b.pluginElement=document.getElementById(b.id); |
||||
b.pluginApi=b.pluginElement.Content.MediaElementJS}b.pluginApi!=null&&b.success&&b.success(b,c)}},fireEvent:function(a,b,c){var d,e;if(a=this.pluginMediaElements[a]){b={type:b,target:a};for(d in c){a[d]=c[d];b[d]=c[d]}e=c.bufferedTime||0;b.target.buffered=b.buffered={start:function(){return 0},end:function(){return e},length:1};a.dispatchEvent(b.type,b)}}}; |
||||
mejs.MediaElementDefaults={mode:"auto",plugins:["flash","silverlight","youtube","vimeo"],enablePluginDebug:false,httpsBasicAuthSite:false,type:"",pluginPath:mejs.Utility.getScriptPath(["mediaelement.js","mediaelement.min.js","mediaelement-and-player.js","mediaelement-and-player.min.js"]),flashName:"flashmediaelement.swf",flashStreamer:"",enablePluginSmoothing:false,enablePseudoStreaming:false,pseudoStreamingStartQueryParam:"start",silverlightName:"silverlightmediaelement.xap",defaultVideoWidth:480, |
||||
defaultVideoHeight:270,pluginWidth:-1,pluginHeight:-1,pluginVars:[],timerRate:250,startVolume:0.8,success:function(){},error:function(){}};mejs.MediaElement=function(a,b){return mejs.HtmlMediaElementShim.create(a,b)}; |
||||
mejs.HtmlMediaElementShim={create:function(a,b){var c=mejs.MediaElementDefaults,d=typeof a=="string"?document.getElementById(a):a,e=d.tagName.toLowerCase(),f=e==="audio"||e==="video",g=f?d.getAttribute("src"):d.getAttribute("href");e=d.getAttribute("poster");var h=d.getAttribute("autoplay"),l=d.getAttribute("preload"),j=d.getAttribute("controls"),k;for(k in b)c[k]=b[k];g=typeof g=="undefined"||g===null||g==""?null:g;e=typeof e=="undefined"||e===null?"":e;l=typeof l=="undefined"||l===null||l==="false"? |
||||
"none":l;h=!(typeof h=="undefined"||h===null||h==="false");j=!(typeof j=="undefined"||j===null||j==="false");k=this.determinePlayback(d,c,mejs.MediaFeatures.supportsMediaTag,f,g);k.url=k.url!==null?mejs.Utility.absolutizeUrl(k.url):"";if(k.method=="native"){if(mejs.MediaFeatures.isBustedAndroid){d.src=k.url;d.addEventListener("click",function(){d.play()},false)}return this.updateNative(k,c,h,l)}else if(k.method!=="")return this.createPlugin(k,c,e,h,l,j);else{this.createErrorMessage(k,c,e);return this}}, |
||||
determinePlayback:function(a,b,c,d,e){var f=[],g,h,l,j={method:"",url:"",htmlMediaElement:a,isVideo:a.tagName.toLowerCase()!="audio"},k;if(typeof b.type!="undefined"&&b.type!=="")if(typeof b.type=="string")f.push({type:b.type,url:e});else for(g=0;g<b.type.length;g++)f.push({type:b.type[g],url:e});else if(e!==null){l=this.formatType(e,a.getAttribute("type"));f.push({type:l,url:e})}else for(g=0;g<a.childNodes.length;g++){h=a.childNodes[g];if(h.nodeType==1&&h.tagName.toLowerCase()=="source"){e=h.getAttribute("src"); |
||||
l=this.formatType(e,h.getAttribute("type"));h=h.getAttribute("media");if(!h||!window.matchMedia||window.matchMedia&&window.matchMedia(h).matches)f.push({type:l,url:e})}}if(!d&&f.length>0&&f[0].url!==null&&this.getTypeFromFile(f[0].url).indexOf("audio")>-1)j.isVideo=false;if(mejs.MediaFeatures.isBustedAndroid)a.canPlayType=function(m){return m.match(/video\/(mp4|m4v)/gi)!==null?"maybe":""};if(c&&(b.mode==="auto"||b.mode==="auto_plugin"||b.mode==="native")&&!(mejs.MediaFeatures.isBustedNativeHTTPS&& |
||||
b.httpsBasicAuthSite===true)){if(!d){g=document.createElement(j.isVideo?"video":"audio");a.parentNode.insertBefore(g,a);a.style.display="none";j.htmlMediaElement=a=g}for(g=0;g<f.length;g++)if(a.canPlayType(f[g].type).replace(/no/,"")!==""||a.canPlayType(f[g].type.replace(/mp3/,"mpeg")).replace(/no/,"")!==""){j.method="native";j.url=f[g].url;break}if(j.method==="native"){if(j.url!==null)a.src=j.url;if(b.mode!=="auto_plugin")return j}}if(b.mode==="auto"||b.mode==="auto_plugin"||b.mode==="shim")for(g= |
||||
0;g<f.length;g++){l=f[g].type;for(a=0;a<b.plugins.length;a++){e=b.plugins[a];h=mejs.plugins[e];for(c=0;c<h.length;c++){k=h[c];if(k.version==null||mejs.PluginDetector.hasPluginVersion(e,k.version))for(d=0;d<k.types.length;d++)if(l==k.types[d]){j.method=e;j.url=f[g].url;return j}}}}if(b.mode==="auto_plugin"&&j.method==="native")return j;if(j.method===""&&f.length>0)j.url=f[0].url;return j},formatType:function(a,b){return a&&!b?this.getTypeFromFile(a):b&&~b.indexOf(";")?b.substr(0,b.indexOf(";")):b}, |
||||
getTypeFromFile:function(a){a=a.split("?")[0];a=a.substring(a.lastIndexOf(".")+1).toLowerCase();return(/(mp4|m4v|ogg|ogv|webm|webmv|flv|wmv|mpeg|mov)/gi.test(a)?"video":"audio")+"/"+this.getTypeFromExtension(a)},getTypeFromExtension:function(a){switch(a){case "mp4":case "m4v":return"mp4";case "webm":case "webma":case "webmv":return"webm";case "ogg":case "oga":case "ogv":return"ogg";default:return a}},createErrorMessage:function(a,b,c){var d=a.htmlMediaElement,e=document.createElement("div");e.className= |
||||
"me-cannotplay";try{e.style.width=d.width+"px";e.style.height=d.height+"px"}catch(f){}e.innerHTML=b.customError?b.customError:c!==""?'<a href="'+a.url+'"><img src="'+c+'" width="100%" height="100%" /></a>':'<a href="'+a.url+'"><span>'+mejs.i18n.t("Download File")+"</span></a>";d.parentNode.insertBefore(e,d);d.style.display="none";b.error(d)},createPlugin:function(a,b,c,d,e,f){c=a.htmlMediaElement;var g=1,h=1,l="me_"+a.method+"_"+mejs.meIndex++,j=new mejs.PluginMediaElement(l,a.method,a.url),k=document.createElement("div"), |
||||
m;j.tagName=c.tagName;for(m=0;m<c.attributes.length;m++){var n=c.attributes[m];n.specified==true&&j.setAttribute(n.name,n.value)}for(m=c.parentNode;m!==null&&m.tagName.toLowerCase()!="body";){if(m.parentNode.tagName.toLowerCase()=="p"){m.parentNode.parentNode.insertBefore(m,m.parentNode);break}m=m.parentNode}if(a.isVideo){g=b.pluginWidth>0?b.pluginWidth:b.videoWidth>0?b.videoWidth:c.getAttribute("width")!==null?c.getAttribute("width"):b.defaultVideoWidth;h=b.pluginHeight>0?b.pluginHeight:b.videoHeight> |
||||
0?b.videoHeight:c.getAttribute("height")!==null?c.getAttribute("height"):b.defaultVideoHeight;g=mejs.Utility.encodeUrl(g);h=mejs.Utility.encodeUrl(h)}else if(b.enablePluginDebug){g=320;h=240}j.success=b.success;mejs.MediaPluginBridge.registerPluginElement(l,j,c);k.className="me-plugin";k.id=l+"_container";a.isVideo?c.parentNode.insertBefore(k,c):document.body.insertBefore(k,document.body.childNodes[0]);d=["id="+l,"isvideo="+(a.isVideo?"true":"false"),"autoplay="+(d?"true":"false"),"preload="+e,"width="+ |
||||
g,"startvolume="+b.startVolume,"timerrate="+b.timerRate,"flashstreamer="+b.flashStreamer,"height="+h,"pseudostreamstart="+b.pseudoStreamingStartQueryParam];if(a.url!==null)a.method=="flash"?d.push("file="+mejs.Utility.encodeUrl(a.url)):d.push("file="+a.url);b.enablePluginDebug&&d.push("debug=true");b.enablePluginSmoothing&&d.push("smoothing=true");b.enablePseudoStreaming&&d.push("pseudostreaming=true");f&&d.push("controls=true");if(b.pluginVars)d=d.concat(b.pluginVars);switch(a.method){case "silverlight":k.innerHTML= |
||||
'<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" id="'+l+'" name="'+l+'" width="'+g+'" height="'+h+'" class="mejs-shim"><param name="initParams" value="'+d.join(",")+'" /><param name="windowless" value="true" /><param name="background" value="black" /><param name="minRuntimeVersion" value="3.0.0.0" /><param name="autoUpgrade" value="true" /><param name="source" value="'+b.pluginPath+b.silverlightName+'" /></object>';break;case "flash":if(mejs.MediaFeatures.isIE){a= |
||||
document.createElement("div");k.appendChild(a);a.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" id="'+l+'" width="'+g+'" height="'+h+'" class="mejs-shim"><param name="movie" value="'+b.pluginPath+b.flashName+"?x="+new Date+'" /><param name="flashvars" value="'+d.join("&")+'" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /></object>'}else k.innerHTML= |
||||
'<embed id="'+l+'" name="'+l+'" play="true" loop="false" quality="high" bgcolor="#000000" wmode="transparent" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="//www.macromedia.com/go/getflashplayer" src="'+b.pluginPath+b.flashName+'" flashvars="'+d.join("&")+'" width="'+g+'" height="'+h+'" class="mejs-shim"></embed>';break;case "youtube":b=a.url.substr(a.url.lastIndexOf("=")+1);youtubeSettings={container:k,containerId:k.id,pluginMediaElement:j,pluginId:l, |
||||
videoId:b,height:h,width:g};mejs.PluginDetector.hasPluginVersion("flash",[10,0,0])?mejs.YouTubeApi.createFlash(youtubeSettings):mejs.YouTubeApi.enqueueIframe(youtubeSettings);break;case "vimeo":j.vimeoid=a.url.substr(a.url.lastIndexOf("/")+1);k.innerHTML='<iframe src="http://player.vimeo.com/video/'+j.vimeoid+'?portrait=0&byline=0&title=0" width="'+g+'" height="'+h+'" frameborder="0" class="mejs-shim"></iframe>'}c.style.display="none";c.removeAttribute("autoplay");return j},updateNative:function(a, |
||||
b){var c=a.htmlMediaElement,d;for(d in mejs.HtmlMediaElement)c[d]=mejs.HtmlMediaElement[d];b.success(c,c);return c}}; |
||||
mejs.YouTubeApi={isIframeStarted:false,isIframeLoaded:false,loadIframeApi:function(){if(!this.isIframeStarted){var a=document.createElement("script");a.src="//www.youtube.com/player_api";var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b);this.isIframeStarted=true}},iframeQueue:[],enqueueIframe:function(a){if(this.isLoaded)this.createIframe(a);else{this.loadIframeApi();this.iframeQueue.push(a)}},createIframe:function(a){var b=a.pluginMediaElement,c=new YT.Player(a.containerId, |
||||
{height:a.height,width:a.width,videoId:a.videoId,playerVars:{controls:0},events:{onReady:function(){a.pluginMediaElement.pluginApi=c;mejs.MediaPluginBridge.initPlugin(a.pluginId);setInterval(function(){mejs.YouTubeApi.createEvent(c,b,"timeupdate")},250)},onStateChange:function(d){mejs.YouTubeApi.handleStateChange(d.data,c,b)}}})},createEvent:function(a,b,c){c={type:c,target:b};if(a&&a.getDuration){b.currentTime=c.currentTime=a.getCurrentTime();b.duration=c.duration=a.getDuration();c.paused=b.paused; |
||||
c.ended=b.ended;c.muted=a.isMuted();c.volume=a.getVolume()/100;c.bytesTotal=a.getVideoBytesTotal();c.bufferedBytes=a.getVideoBytesLoaded();var d=c.bufferedBytes/c.bytesTotal*c.duration;c.target.buffered=c.buffered={start:function(){return 0},end:function(){return d},length:1}}b.dispatchEvent(c.type,c)},iFrameReady:function(){for(this.isIframeLoaded=this.isLoaded=true;this.iframeQueue.length>0;)this.createIframe(this.iframeQueue.pop())},flashPlayers:{},createFlash:function(a){this.flashPlayers[a.pluginId]= |
||||
a;var b,c="//www.youtube.com/apiplayer?enablejsapi=1&playerapiid="+a.pluginId+"&version=3&autoplay=0&controls=0&modestbranding=1&loop=0";if(mejs.MediaFeatures.isIE){b=document.createElement("div");a.container.appendChild(b);b.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" id="'+a.pluginId+'" width="'+a.width+'" height="'+a.height+'" class="mejs-shim"><param name="movie" value="'+ |
||||
c+'" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /></object>'}else a.container.innerHTML='<object type="application/x-shockwave-flash" id="'+a.pluginId+'" data="'+c+'" width="'+a.width+'" height="'+a.height+'" style="visibility: visible; " class="mejs-shim"><param name="allowScriptAccess" value="always"><param name="wmode" value="transparent"></object>'},flashReady:function(a){var b=this.flashPlayers[a],c= |
||||
document.getElementById(a),d=b.pluginMediaElement;d.pluginApi=d.pluginElement=c;mejs.MediaPluginBridge.initPlugin(a);c.cueVideoById(b.videoId);a=b.containerId+"_callback";window[a]=function(e){mejs.YouTubeApi.handleStateChange(e,c,d)};c.addEventListener("onStateChange",a);setInterval(function(){mejs.YouTubeApi.createEvent(c,d,"timeupdate")},250)},handleStateChange:function(a,b,c){switch(a){case -1:c.paused=true;c.ended=true;mejs.YouTubeApi.createEvent(b,c,"loadedmetadata");break;case 0:c.paused=false; |
||||
c.ended=true;mejs.YouTubeApi.createEvent(b,c,"ended");break;case 1:c.paused=false;c.ended=false;mejs.YouTubeApi.createEvent(b,c,"play");mejs.YouTubeApi.createEvent(b,c,"playing");break;case 2:c.paused=true;c.ended=false;mejs.YouTubeApi.createEvent(b,c,"pause");break;case 3:mejs.YouTubeApi.createEvent(b,c,"progress")}}};function onYouTubePlayerAPIReady(){mejs.YouTubeApi.iFrameReady()}function onYouTubePlayerReady(a){mejs.YouTubeApi.flashReady(a)}window.mejs=mejs;window.MediaElement=mejs.MediaElement; |
||||
(function(a,b){var c={locale:{language:"",strings:{}},methods:{}};c.locale.getLanguage=function(){return c.locale.language||navigator.language};if(typeof mejsL10n!="undefined")c.locale.language=mejsL10n.language;c.locale.INIT_LANGUAGE=c.locale.getLanguage();c.methods.checkPlain=function(d){var e,f,g={"&":"&",'"':""","<":"<",">":">"};d=String(d);for(e in g)if(g.hasOwnProperty(e)){f=RegExp(e,"g");d=d.replace(f,g[e])}return d};c.methods.formatString=function(d,e){for(var f in e){switch(f.charAt(0)){case "@":e[f]= |
||||
c.methods.checkPlain(e[f]);break;case "!":break;default:e[f]='<em class="placeholder">'+c.methods.checkPlain(e[f])+"</em>"}d=d.replace(f,e[f])}return d};c.methods.t=function(d,e,f){if(c.locale.strings&&c.locale.strings[f.context]&&c.locale.strings[f.context][d])d=c.locale.strings[f.context][d];if(e)d=c.methods.formatString(d,e);return d};c.t=function(d,e,f){if(typeof d==="string"&&d.length>0){var g=c.locale.getLanguage();f=f||{context:g};return c.methods.t(d,e,f)}else throw{name:"InvalidArgumentException", |
||||
message:"First argument is either not a string or empty."};};b.i18n=c})(document,mejs);(function(a){if(typeof mejsL10n!="undefined")a[mejsL10n.language]=mejsL10n.strings})(mejs.i18n.locale.strings);(function(a){a.de={Fullscreen:"Vollbild","Go Fullscreen":"Vollbild an","Turn off Fullscreen":"Vollbild aus",Close:"Schlie\u00dfen"}})(mejs.i18n.locale.strings); |
||||
(function(a){a.zh={Fullscreen:"\u5168\u87a2\u5e55","Go Fullscreen":"\u5168\u5c4f\u6a21\u5f0f","Turn off Fullscreen":"\u9000\u51fa\u5168\u5c4f\u6a21\u5f0f",Close:"\u95dc\u9589"}})(mejs.i18n.locale.strings); |
||||
@ -0,0 +1,870 @@ |
||||
.mejs-container { |
||||
position: relative; |
||||
background: #000; |
||||
font-family: Helvetica, Arial; |
||||
text-align: left; |
||||
vertical-align: top; |
||||
text-indent: 0; |
||||
} |
||||
|
||||
.me-plugin { |
||||
position: absolute; |
||||
} |
||||
|
||||
.mejs-embed, .mejs-embed body { |
||||
width: 100%; |
||||
height: 100%; |
||||
margin: 0; |
||||
padding: 0; |
||||
background: #000; |
||||
overflow: hidden; |
||||
} |
||||
|
||||
.mejs-fullscreen { |
||||
/* set it to not show scroll bars so 100% will work */ |
||||
overflow: hidden !important; |
||||
} |
||||
|
||||
.mejs-container-fullscreen { |
||||
position: fixed; |
||||
left: 0; |
||||
top: 0; |
||||
right: 0; |
||||
bottom: 0; |
||||
overflow: hidden; |
||||
z-index: 1000; |
||||
} |
||||
.mejs-container-fullscreen .mejs-mediaelement, |
||||
.mejs-container-fullscreen video { |
||||
width: 100%; |
||||
height: 100%; |
||||
} |
||||
|
||||
.mejs-clear { |
||||
clear: both; |
||||
} |
||||
|
||||
/* Start: LAYERS */ |
||||
.mejs-background { |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
} |
||||
|
||||
.mejs-mediaelement { |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
width: 100%; |
||||
height: 100%; |
||||
} |
||||
|
||||
.mejs-poster { |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
background-size: contain ; |
||||
background-position: 50% 50% ; |
||||
background-repeat: no-repeat ; |
||||
} |
||||
:root .mejs-poster img { |
||||
display: none ; |
||||
} |
||||
|
||||
.mejs-poster img { |
||||
border: 0; |
||||
padding: 0; |
||||
border: 0; |
||||
} |
||||
|
||||
.mejs-overlay { |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
} |
||||
|
||||
.mejs-overlay-play { |
||||
cursor: pointer; |
||||
} |
||||
|
||||
.mejs-overlay-button { |
||||
position: absolute; |
||||
top: 50%; |
||||
left: 50%; |
||||
width: 100px; |
||||
height: 100px; |
||||
margin: -50px 0 0 -50px; |
||||
background: url(bigplay.svg) no-repeat; |
||||
} |
||||
|
||||
.no-svg .mejs-overlay-button { |
||||
background-image: url(bigplay.png); |
||||
} |
||||
|
||||
.mejs-overlay:hover .mejs-overlay-button { |
||||
background-position: 0 -100px ; |
||||
} |
||||
|
||||
.mejs-overlay-loading { |
||||
position: absolute; |
||||
top: 50%; |
||||
left: 50%; |
||||
width: 80px; |
||||
height: 80px; |
||||
margin: -40px 0 0 -40px; |
||||
background: #333; |
||||
background: url(background.png); |
||||
background: rgba(0, 0, 0, 0.9); |
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(50,50,50,0.9)), to(rgba(0,0,0,0.9))); |
||||
background: -webkit-linear-gradient(top, rgba(50,50,50,0.9), rgba(0,0,0,0.9)); |
||||
background: -moz-linear-gradient(top, rgba(50,50,50,0.9), rgba(0,0,0,0.9)); |
||||
background: -o-linear-gradient(top, rgba(50,50,50,0.9), rgba(0,0,0,0.9)); |
||||
background: -ms-linear-gradient(top, rgba(50,50,50,0.9), rgba(0,0,0,0.9)); |
||||
background: linear-gradient(rgba(50,50,50,0.9), rgba(0,0,0,0.9)); |
||||
} |
||||
|
||||
.mejs-overlay-loading span { |
||||
display: block; |
||||
width: 80px; |
||||
height: 80px; |
||||
background: transparent url(loading.gif) 50% 50% no-repeat; |
||||
} |
||||
|
||||
/* End: LAYERS */ |
||||
|
||||
/* Start: CONTROL BAR */ |
||||
.mejs-container .mejs-controls { |
||||
position: absolute; |
||||
list-style-type: none; |
||||
margin: 0; |
||||
padding: 0; |
||||
bottom: 0; |
||||
left: 0; |
||||
background: url(background.png); |
||||
background: rgba(0, 0, 0, 0.7); |
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(50,50,50,0.7)), to(rgba(0,0,0,0.7))); |
||||
background: -webkit-linear-gradient(top, rgba(50,50,50,0.7), rgba(0,0,0,0.7)); |
||||
background: -moz-linear-gradient(top, rgba(50,50,50,0.7), rgba(0,0,0,0.7)); |
||||
background: -o-linear-gradient(top, rgba(50,50,50,0.7), rgba(0,0,0,0.7)); |
||||
background: -ms-linear-gradient(top, rgba(50,50,50,0.7), rgba(0,0,0,0.7)); |
||||
background: linear-gradient(rgba(50,50,50,0.7), rgba(0,0,0,0.7)); |
||||
height: 30px; |
||||
width: 100%; |
||||
} |
||||
.mejs-container .mejs-controls div { |
||||
list-style-type: none; |
||||
background-image: none; |
||||
display: block; |
||||
float: left; |
||||
margin: 0; |
||||
padding: 0; |
||||
width: 26px; |
||||
height: 26px; |
||||
font-size: 11px; |
||||
line-height: 11px; |
||||
font-family: Helvetica, Arial; |
||||
border: 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-button button { |
||||
cursor: pointer; |
||||
display: block; |
||||
font-size: 0; |
||||
line-height: 0; |
||||
text-decoration: none; |
||||
margin: 7px 5px; |
||||
padding: 0; |
||||
position: absolute; |
||||
height: 16px; |
||||
width: 16px; |
||||
border: 0; |
||||
background: transparent url(controls.svg) no-repeat; |
||||
} |
||||
|
||||
.no-svg .mejs-controls .mejs-button button { |
||||
background-image: url(controls.png); |
||||
} |
||||
|
||||
/* :focus for accessibility */ |
||||
.mejs-controls .mejs-button button:focus { |
||||
outline: solid 1px yellow; |
||||
} |
||||
|
||||
/* End: CONTROL BAR */ |
||||
|
||||
/* Start: Time (Current / Duration) */ |
||||
.mejs-container .mejs-controls .mejs-time { |
||||
color: #fff; |
||||
display: block; |
||||
height: 17px; |
||||
width: auto; |
||||
padding: 8px 3px 0 3px ; |
||||
overflow: hidden; |
||||
text-align: center; |
||||
-moz-box-sizing: content-box; |
||||
-webkit-box-sizing: content-box; |
||||
box-sizing: content-box; |
||||
} |
||||
|
||||
.mejs-container .mejs-controls .mejs-time span { |
||||
color: #fff; |
||||
font-size: 11px; |
||||
line-height: 12px; |
||||
display: block; |
||||
float: left; |
||||
margin: 1px 2px 0 0; |
||||
width: auto; |
||||
} |
||||
/* End: Time (Current / Duration) */ |
||||
|
||||
/* Start: Play/Pause/Stop */ |
||||
.mejs-controls .mejs-play button { |
||||
background-position: 0 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-pause button { |
||||
background-position: 0 -16px; |
||||
} |
||||
|
||||
.mejs-controls .mejs-stop button { |
||||
background-position: -112px 0; |
||||
} |
||||
/* Start: Play/Pause/Stop */ |
||||
|
||||
/* Start: Progress Bar */ |
||||
.mejs-controls div.mejs-time-rail { |
||||
direction: ltr; |
||||
width: 200px; |
||||
padding-top: 5px; |
||||
} |
||||
|
||||
.mejs-controls .mejs-time-rail span { |
||||
display: block; |
||||
position: absolute; |
||||
width: 180px; |
||||
height: 10px; |
||||
-webkit-border-radius: 2px; |
||||
-moz-border-radius: 2px; |
||||
border-radius: 2px; |
||||
cursor: pointer; |
||||
} |
||||
|
||||
.mejs-controls .mejs-time-rail .mejs-time-total { |
||||
margin: 5px; |
||||
background: #333; |
||||
background: rgba(50,50,50,0.8); |
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(30,30,30,0.8)), to(rgba(60,60,60,0.8))); |
||||
background: -webkit-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8)); |
||||
background: -moz-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8)); |
||||
background: -o-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8)); |
||||
background: -ms-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8)); |
||||
background: linear-gradient(rgba(30,30,30,0.8), rgba(60,60,60,0.8)); |
||||
} |
||||
|
||||
.mejs-controls .mejs-time-rail .mejs-time-buffering { |
||||
width: 100%; |
||||
background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); |
||||
background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent)); |
||||
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); |
||||
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); |
||||
background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); |
||||
background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); |
||||
-webkit-background-size: 15px 15px; |
||||
-moz-background-size: 15px 15px; |
||||
-o-background-size: 15px 15px; |
||||
background-size: 15px 15px; |
||||
-webkit-animation: buffering-stripes 2s linear infinite; |
||||
-moz-animation: buffering-stripes 2s linear infinite; |
||||
-ms-animation: buffering-stripes 2s linear infinite; |
||||
-o-animation: buffering-stripes 2s linear infinite; |
||||
animation: buffering-stripes 2s linear infinite; |
||||
} |
||||
|
||||
@-webkit-keyframes buffering-stripes { from {background-position: 0 0;} to {background-position: 30px 0;} } |
||||
@-moz-keyframes buffering-stripes { from {background-position: 0 0;} to {background-position: 30px 0;} } |
||||
@-ms-keyframes buffering-stripes { from {background-position: 0 0;} to {background-position: 30px 0;} } |
||||
@-o-keyframes buffering-stripes { from {background-position: 0 0;} to {background-position: 30px 0;} } |
||||
@keyframes buffering-stripes { from {background-position: 0 0;} to {background-position: 30px 0;} } |
||||
|
||||
.mejs-controls .mejs-time-rail .mejs-time-loaded { |
||||
background: #3caac8; |
||||
background: rgba(60,170,200,0.8); |
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(44,124,145,0.8)), to(rgba(78,183,212,0.8))); |
||||
background: -webkit-linear-gradient(top, rgba(44,124,145,0.8), rgba(78,183,212,0.8)); |
||||
background: -moz-linear-gradient(top, rgba(44,124,145,0.8), rgba(78,183,212,0.8)); |
||||
background: -o-linear-gradient(top, rgba(44,124,145,0.8), rgba(78,183,212,0.8)); |
||||
background: -ms-linear-gradient(top, rgba(44,124,145,0.8), rgba(78,183,212,0.8)); |
||||
background: linear-gradient(rgba(44,124,145,0.8), rgba(78,183,212,0.8)); |
||||
width: 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-time-rail .mejs-time-current { |
||||
background: #fff; |
||||
background: rgba(255,255,255,0.8); |
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(255,255,255,0.9)), to(rgba(200,200,200,0.8))); |
||||
background: -webkit-linear-gradient(top, rgba(255,255,255,0.9), rgba(200,200,200,0.8)); |
||||
background: -moz-linear-gradient(top, rgba(255,255,255,0.9), rgba(200,200,200,0.8)); |
||||
background: -o-linear-gradient(top, rgba(255,255,255,0.9), rgba(200,200,200,0.8)); |
||||
background: -ms-linear-gradient(top, rgba(255,255,255,0.9), rgba(200,200,200,0.8)); |
||||
background: linear-gradient(rgba(255,255,255,0.9), rgba(200,200,200,0.8)); |
||||
width: 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-time-rail .mejs-time-handle { |
||||
display: none; |
||||
position: absolute; |
||||
margin: 0; |
||||
width: 10px; |
||||
background: #fff; |
||||
-webkit-border-radius: 5px; |
||||
-moz-border-radius: 5px; |
||||
border-radius: 5px; |
||||
cursor: pointer; |
||||
border: solid 2px #333; |
||||
top: -2px; |
||||
text-align: center; |
||||
} |
||||
|
||||
.mejs-controls .mejs-time-rail .mejs-time-float { |
||||
position: absolute; |
||||
display: none; |
||||
background: #eee; |
||||
width: 36px; |
||||
height: 17px; |
||||
border: solid 1px #333; |
||||
top: -26px; |
||||
margin-left: -18px; |
||||
text-align: center; |
||||
color: #111; |
||||
} |
||||
|
||||
.mejs-controls .mejs-time-rail .mejs-time-float-current { |
||||
margin: 2px; |
||||
width: 30px; |
||||
display: block; |
||||
text-align: center; |
||||
left: 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-time-rail .mejs-time-float-corner { |
||||
position: absolute; |
||||
display: block; |
||||
width: 0; |
||||
height: 0; |
||||
line-height: 0; |
||||
border: solid 5px #eee; |
||||
border-color: #eee transparent transparent transparent; |
||||
-webkit-border-radius: 0; |
||||
-moz-border-radius: 0; |
||||
border-radius: 0; |
||||
top: 15px; |
||||
left: 13px; |
||||
} |
||||
|
||||
.mejs-long-video .mejs-controls .mejs-time-rail .mejs-time-float { |
||||
width: 48px; |
||||
} |
||||
|
||||
.mejs-long-video .mejs-controls .mejs-time-rail .mejs-time-float-current { |
||||
width: 44px; |
||||
} |
||||
|
||||
.mejs-long-video .mejs-controls .mejs-time-rail .mejs-time-float-corner { |
||||
left: 18px; |
||||
} |
||||
|
||||
/* |
||||
.mejs-controls .mejs-time-rail:hover .mejs-time-handle { |
||||
visibility:visible; |
||||
} |
||||
*/ |
||||
/* End: Progress Bar */ |
||||
|
||||
/* Start: Fullscreen */ |
||||
.mejs-controls .mejs-fullscreen-button button { |
||||
background-position: -32px 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-unfullscreen button { |
||||
background-position: -32px -16px; |
||||
} |
||||
/* End: Fullscreen */ |
||||
|
||||
|
||||
/* Start: Mute/Volume */ |
||||
.mejs-controls .mejs-volume-button { |
||||
} |
||||
|
||||
.mejs-controls .mejs-mute button { |
||||
background-position: -16px -16px; |
||||
} |
||||
|
||||
.mejs-controls .mejs-unmute button { |
||||
background-position: -16px 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-volume-button { |
||||
position: relative; |
||||
} |
||||
|
||||
.mejs-controls .mejs-volume-button .mejs-volume-slider { |
||||
display: none; |
||||
height: 115px; |
||||
width: 25px; |
||||
background: url(background.png); |
||||
background: rgba(50, 50, 50, 0.7); |
||||
-webkit-border-radius: 0; |
||||
-moz-border-radius: 0; |
||||
border-radius: 0; |
||||
top: -115px; |
||||
left: 0; |
||||
z-index: 1; |
||||
position: absolute; |
||||
margin: 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-volume-button:hover { |
||||
-webkit-border-radius: 0 0 4px 4px; |
||||
-moz-border-radius: 0 0 4px 4px; |
||||
border-radius: 0 0 4px 4px; |
||||
} |
||||
|
||||
/* |
||||
.mejs-controls .mejs-volume-button:hover .mejs-volume-slider { |
||||
display: block; |
||||
} |
||||
*/ |
||||
|
||||
.mejs-controls .mejs-volume-button .mejs-volume-slider .mejs-volume-total { |
||||
position: absolute; |
||||
left: 11px; |
||||
top: 8px; |
||||
width: 2px; |
||||
height: 100px; |
||||
background: #ddd; |
||||
background: rgba(255, 255, 255, 0.5); |
||||
margin: 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-volume-button .mejs-volume-slider .mejs-volume-current { |
||||
position: absolute; |
||||
left: 11px; |
||||
top: 8px; |
||||
width: 2px; |
||||
height: 100px; |
||||
background: #ddd; |
||||
background: rgba(255, 255, 255, 0.9); |
||||
margin: 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-volume-button .mejs-volume-slider .mejs-volume-handle { |
||||
position: absolute; |
||||
left: 4px; |
||||
top: -3px; |
||||
width: 16px; |
||||
height: 6px; |
||||
background: #ddd; |
||||
background: rgba(255, 255, 255, 0.9); |
||||
cursor: N-resize; |
||||
-webkit-border-radius: 1px; |
||||
-moz-border-radius: 1px; |
||||
border-radius: 1px; |
||||
margin: 0; |
||||
} |
||||
|
||||
/* horizontal version */ |
||||
.mejs-controls div.mejs-horizontal-volume-slider { |
||||
height: 26px; |
||||
width: 60px; |
||||
position: relative; |
||||
} |
||||
|
||||
.mejs-controls .mejs-horizontal-volume-slider .mejs-horizontal-volume-total { |
||||
position: absolute; |
||||
left: 0; |
||||
top: 11px; |
||||
width: 50px; |
||||
height: 8px; |
||||
margin: 0; |
||||
padding: 0; |
||||
font-size: 1px; |
||||
-webkit-border-radius: 2px; |
||||
-moz-border-radius: 2px; |
||||
border-radius: 2px; |
||||
background: #333; |
||||
background: rgba(50,50,50,0.8); |
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(30,30,30,0.8)), to(rgba(60,60,60,0.8))); |
||||
background: -webkit-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8)); |
||||
background: -moz-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8)); |
||||
background: -o-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8)); |
||||
background: -ms-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8)); |
||||
background: linear-gradient(rgba(30,30,30,0.8), rgba(60,60,60,0.8)); |
||||
} |
||||
|
||||
.mejs-controls .mejs-horizontal-volume-slider .mejs-horizontal-volume-current { |
||||
position: absolute; |
||||
left: 0; |
||||
top: 11px; |
||||
width: 50px; |
||||
height: 8px; |
||||
margin: 0; |
||||
padding: 0; |
||||
font-size: 1px; |
||||
-webkit-border-radius: 2px; |
||||
-moz-border-radius: 2px; |
||||
border-radius: 2px; |
||||
background: #fff; |
||||
background: rgba(255,255,255,0.8); |
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(255,255,255,0.9)), to(rgba(200,200,200,0.8))); |
||||
background: -webkit-linear-gradient(top, rgba(255,255,255,0.9), rgba(200,200,200,0.8)); |
||||
background: -moz-linear-gradient(top, rgba(255,255,255,0.9), rgba(200,200,200,0.8)); |
||||
background: -o-linear-gradient(top, rgba(255,255,255,0.9), rgba(200,200,200,0.8)); |
||||
background: -ms-linear-gradient(top, rgba(255,255,255,0.9), rgba(200,200,200,0.8)); |
||||
background: linear-gradient(rgba(255,255,255,0.9), rgba(200,200,200,0.8)); |
||||
} |
||||
|
||||
.mejs-controls .mejs-horizontal-volume-slider .mejs-horizontal-volume-handle { |
||||
display: none; |
||||
} |
||||
|
||||
/* End: Mute/Volume */ |
||||
|
||||
/* Start: Track (Captions and Chapters) */ |
||||
.mejs-controls .mejs-captions-button { |
||||
position: relative; |
||||
} |
||||
|
||||
.mejs-controls .mejs-captions-button button { |
||||
background-position: -48px 0; |
||||
} |
||||
.mejs-controls .mejs-captions-button .mejs-captions-selector { |
||||
visibility: hidden; |
||||
position: absolute; |
||||
bottom: 26px; |
||||
right: -10px; |
||||
width: 130px; |
||||
height: 100px; |
||||
background: url(background.png); |
||||
background: rgba(50,50,50,0.7); |
||||
border: solid 1px transparent; |
||||
padding: 10px; |
||||
overflow: hidden; |
||||
-webkit-border-radius: 0; |
||||
-moz-border-radius: 0; |
||||
border-radius: 0; |
||||
} |
||||
|
||||
/* |
||||
.mejs-controls .mejs-captions-button:hover .mejs-captions-selector { |
||||
visibility: visible; |
||||
} |
||||
*/ |
||||
|
||||
.mejs-controls .mejs-captions-button .mejs-captions-selector ul { |
||||
margin: 0; |
||||
padding: 0; |
||||
display: block; |
||||
list-style-type: none !important; |
||||
overflow: hidden; |
||||
} |
||||
|
||||
.mejs-controls .mejs-captions-button .mejs-captions-selector ul li { |
||||
margin: 0 0 6px 0; |
||||
padding: 0; |
||||
list-style-type: none !important; |
||||
display: block; |
||||
color: #fff; |
||||
overflow: hidden; |
||||
} |
||||
|
||||
.mejs-controls .mejs-captions-button .mejs-captions-selector ul li input { |
||||
clear: both; |
||||
float: left; |
||||
margin: 3px 3px 0 5px; |
||||
} |
||||
|
||||
.mejs-controls .mejs-captions-button .mejs-captions-selector ul li label { |
||||
width: 100px; |
||||
float: left; |
||||
padding: 4px 0 0 0; |
||||
line-height: 15px; |
||||
font-family: helvetica, arial; |
||||
font-size: 10px; |
||||
} |
||||
|
||||
.mejs-controls .mejs-captions-button .mejs-captions-translations { |
||||
font-size: 10px; |
||||
margin: 0 0 5px 0; |
||||
} |
||||
|
||||
.mejs-chapters { |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
-xborder-right: solid 1px #fff; |
||||
width: 10000px; |
||||
z-index: 1; |
||||
} |
||||
|
||||
.mejs-chapters .mejs-chapter { |
||||
position: absolute; |
||||
float: left; |
||||
background: #222; |
||||
background: rgba(0, 0, 0, 0.7); |
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(50,50,50,0.7)), to(rgba(0,0,0,0.7))); |
||||
background: -webkit-linear-gradient(top, rgba(50,50,50,0.7), rgba(0,0,0,0.7)); |
||||
background: -moz-linear-gradient(top, rgba(50,50,50,0.7), rgba(0,0,0,0.7)); |
||||
background: -o-linear-gradient(top, rgba(50,50,50,0.7), rgba(0,0,0,0.7)); |
||||
background: -ms-linear-gradient(top, rgba(50,50,50,0.7), rgba(0,0,0,0.7)); |
||||
background: linear-gradient(rgba(50,50,50,0.7), rgba(0,0,0,0.7)); |
||||
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, startColorstr=#323232,endColorstr=#000000); |
||||
overflow: hidden; |
||||
border: 0; |
||||
} |
||||
|
||||
.mejs-chapters .mejs-chapter .mejs-chapter-block { |
||||
font-size: 11px; |
||||
color: #fff; |
||||
padding: 5px; |
||||
display: block; |
||||
border-right: solid 1px #333; |
||||
border-bottom: solid 1px #333; |
||||
cursor: pointer; |
||||
} |
||||
|
||||
.mejs-chapters .mejs-chapter .mejs-chapter-block-last { |
||||
border-right: none; |
||||
} |
||||
|
||||
.mejs-chapters .mejs-chapter .mejs-chapter-block:hover { |
||||
background: #666; |
||||
background: rgba(102,102,102, 0.7); |
||||
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(102,102,102,0.7)), to(rgba(50,50,50,0.6))); |
||||
background: -webkit-linear-gradient(top, rgba(102,102,102,0.7), rgba(50,50,50,0.6)); |
||||
background: -moz-linear-gradient(top, rgba(102,102,102,0.7), rgba(50,50,50,0.6)); |
||||
background: -o-linear-gradient(top, rgba(102,102,102,0.7), rgba(50,50,50,0.6)); |
||||
background: -ms-linear-gradient(top, rgba(102,102,102,0.7), rgba(50,50,50,0.6)); |
||||
background: linear-gradient(rgba(102,102,102,0.7), rgba(50,50,50,0.6)); |
||||
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, startColorstr=#666666,endColorstr=#323232); |
||||
} |
||||
|
||||
.mejs-chapters .mejs-chapter .mejs-chapter-block .ch-title { |
||||
font-size: 12px; |
||||
font-weight: bold; |
||||
display: block; |
||||
white-space: nowrap; |
||||
text-overflow: ellipsis; |
||||
margin: 0 0 3px 0; |
||||
line-height: 12px; |
||||
} |
||||
|
||||
.mejs-chapters .mejs-chapter .mejs-chapter-block .ch-timespan { |
||||
font-size: 12px; |
||||
line-height: 12px; |
||||
margin: 3px 0 4px 0; |
||||
display: block; |
||||
white-space: nowrap; |
||||
text-overflow: ellipsis; |
||||
} |
||||
|
||||
.mejs-captions-layer { |
||||
position: absolute; |
||||
bottom: 0; |
||||
left: 0; |
||||
text-align:center; |
||||
line-height: 22px; |
||||
font-size: 12px; |
||||
color: #fff; |
||||
} |
||||
|
||||
.mejs-captions-layer a { |
||||
color: #fff; |
||||
text-decoration: underline; |
||||
} |
||||
|
||||
.mejs-captions-layer[lang=ar] { |
||||
font-size: 20px; |
||||
font-weight: normal; |
||||
} |
||||
|
||||
.mejs-captions-position { |
||||
position: absolute; |
||||
width: 100%; |
||||
bottom: 15px; |
||||
left: 0; |
||||
} |
||||
|
||||
.mejs-captions-position-hover { |
||||
bottom: 45px; |
||||
} |
||||
|
||||
.mejs-captions-text { |
||||
padding: 3px 5px; |
||||
background: url(background.png); |
||||
background: rgba(20, 20, 20, 0.8); |
||||
|
||||
} |
||||
/* End: Track (Captions and Chapters) */ |
||||
|
||||
/* Start: Error */ |
||||
.me-cannotplay { |
||||
} |
||||
|
||||
.me-cannotplay a { |
||||
color: #fff; |
||||
font-weight: bold; |
||||
} |
||||
|
||||
.me-cannotplay span { |
||||
padding: 15px; |
||||
display: block; |
||||
} |
||||
/* End: Error */ |
||||
|
||||
|
||||
/* Start: Loop */ |
||||
.mejs-controls .mejs-loop-off button { |
||||
background-position: -64px -16px; |
||||
} |
||||
|
||||
.mejs-controls .mejs-loop-on button { |
||||
background-position: -64px 0; |
||||
} |
||||
|
||||
/* End: Loop */ |
||||
|
||||
/* Start: backlight */ |
||||
.mejs-controls .mejs-backlight-off button { |
||||
background-position: -80px -16px; |
||||
} |
||||
|
||||
.mejs-controls .mejs-backlight-on button { |
||||
background-position: -80px 0; |
||||
} |
||||
/* End: backlight */ |
||||
|
||||
/* Start: Picture Controls */ |
||||
.mejs-controls .mejs-picturecontrols-button { |
||||
background-position: -96px 0; |
||||
} |
||||
/* End: Picture Controls */ |
||||
|
||||
|
||||
/* context menu */ |
||||
.mejs-contextmenu { |
||||
position: absolute; |
||||
width: 150px; |
||||
padding: 10px; |
||||
border-radius: 4px; |
||||
top: 0; |
||||
left: 0; |
||||
background: #fff; |
||||
border: solid 1px #999; |
||||
z-index: 1001; /* make sure it shows on fullscreen */ |
||||
} |
||||
.mejs-contextmenu .mejs-contextmenu-separator { |
||||
height: 1px; |
||||
font-size: 0; |
||||
margin: 5px 6px; |
||||
background: #333; |
||||
} |
||||
|
||||
.mejs-contextmenu .mejs-contextmenu-item { |
||||
font-family: Helvetica, Arial; |
||||
font-size: 12px; |
||||
padding: 4px 6px; |
||||
cursor: pointer; |
||||
color: #333; |
||||
} |
||||
.mejs-contextmenu .mejs-contextmenu-item:hover { |
||||
background: #2C7C91; |
||||
color: #fff; |
||||
} |
||||
|
||||
/* Start: Source Chooser */ |
||||
.mejs-controls .mejs-sourcechooser-button { |
||||
position: relative; |
||||
} |
||||
|
||||
.mejs-controls .mejs-sourcechooser-button button { |
||||
background-position: -128px 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector { |
||||
visibility: hidden; |
||||
position: absolute; |
||||
bottom: 26px; |
||||
right: -10px; |
||||
width: 130px; |
||||
height: 100px; |
||||
background: url(background.png); |
||||
background: rgba(50,50,50,0.7); |
||||
border: solid 1px transparent; |
||||
padding: 10px; |
||||
overflow: hidden; |
||||
-webkit-border-radius: 0; |
||||
-moz-border-radius: 0; |
||||
border-radius: 0; |
||||
} |
||||
|
||||
.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul { |
||||
margin: 0; |
||||
padding: 0; |
||||
display: block; |
||||
list-style-type: none !important; |
||||
overflow: hidden; |
||||
} |
||||
|
||||
.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li { |
||||
margin: 0 0 6px 0; |
||||
padding: 0; |
||||
list-style-type: none !important; |
||||
display: block; |
||||
color: #fff; |
||||
overflow: hidden; |
||||
} |
||||
|
||||
.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li input { |
||||
clear: both; |
||||
float: left; |
||||
margin: 3px 3px 0 5px; |
||||
} |
||||
|
||||
.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li label { |
||||
width: 100px; |
||||
float: left; |
||||
padding: 4px 0 0 0; |
||||
line-height: 15px; |
||||
font-family: helvetica, arial; |
||||
font-size: 10px; |
||||
} |
||||
/* End: Source Chooser */ |
||||
|
||||
/* Start: Postroll */ |
||||
.mejs-postroll-layer { |
||||
position: absolute; |
||||
bottom: 0; |
||||
left: 0; |
||||
width: 100%; |
||||
height: 100%; |
||||
background: url(background.png); |
||||
background: rgba(50,50,50,0.7); |
||||
z-index: 1000; |
||||
overflow: hidden; |
||||
} |
||||
.mejs-postroll-layer-content { |
||||
width: 100%; |
||||
height: 100%; |
||||
} |
||||
.mejs-postroll-close { |
||||
position: absolute; |
||||
right: 0; |
||||
top: 0; |
||||
background: url(background.png); |
||||
background: rgba(50,50,50,0.7); |
||||
color: #fff; |
||||
padding: 4px; |
||||
z-index: 100; |
||||
cursor: pointer; |
||||
} |
||||
/* End: Postroll */ |
||||
@ -0,0 +1,103 @@ |
||||
/*! |
||||
* MediaElementPlayer |
||||
* http://mediaelementjs.com/
|
||||
* |
||||
* Creates a controller bar for HTML5 <video> add <audio> tags |
||||
* using jQuery and MediaElement.js (HTML5 Flash/Silverlight wrapper) |
||||
* |
||||
* Copyright 2010-2013, John Dyer (http://j.hn/)
|
||||
* License: MIT |
||||
* |
||||
*/if(typeof jQuery!="undefined")mejs.$=jQuery;else if(typeof ender!="undefined")mejs.$=ender; |
||||
(function(f){mejs.MepDefaults={poster:"",showPosterWhenEnded:false,defaultVideoWidth:480,defaultVideoHeight:270,videoWidth:-1,videoHeight:-1,defaultAudioWidth:400,defaultAudioHeight:30,defaultSeekBackwardInterval:function(a){return a.duration*0.05},defaultSeekForwardInterval:function(a){return a.duration*0.05},audioWidth:-1,audioHeight:-1,startVolume:0.8,loop:false,autoRewind:true,enableAutosize:true,alwaysShowHours:false,showTimecodeFrameCount:false,framesPerSecond:25,autosizeProgress:true,alwaysShowControls:false, |
||||
hideVideoControlsOnLoad:false,clickToPlayPause:true,iPadUseNativeControls:false,iPhoneUseNativeControls:false,AndroidUseNativeControls:false,features:["playpause","current","progress","duration","tracks","volume","fullscreen"],isVideo:true,enableKeyboard:true,pauseOtherPlayers:true,keyActions:[{keys:[32,179],action:function(a,b){b.paused||b.ended?b.play():b.pause()}},{keys:[38],action:function(a,b){b.setVolume(Math.min(b.volume+0.1,1))}},{keys:[40],action:function(a,b){b.setVolume(Math.max(b.volume- |
||||
0.1,0))}},{keys:[37,227],action:function(a,b){if(!isNaN(b.duration)&&b.duration>0){if(a.isVideo){a.showControls();a.startControlsTimer()}var c=Math.max(b.currentTime-a.options.defaultSeekBackwardInterval(b),0);b.setCurrentTime(c)}}},{keys:[39,228],action:function(a,b){if(!isNaN(b.duration)&&b.duration>0){if(a.isVideo){a.showControls();a.startControlsTimer()}var c=Math.min(b.currentTime+a.options.defaultSeekForwardInterval(b),b.duration);b.setCurrentTime(c)}}},{keys:[70],action:function(a){if(typeof a.enterFullScreen!= |
||||
"undefined")a.isFullScreen?a.exitFullScreen():a.enterFullScreen()}}]};mejs.mepIndex=0;mejs.players={};mejs.MediaElementPlayer=function(a,b){if(!(this instanceof mejs.MediaElementPlayer))return new mejs.MediaElementPlayer(a,b);this.$media=this.$node=f(a);this.node=this.media=this.$media[0];if(typeof this.node.player!="undefined")return this.node.player;else this.node.player=this;if(typeof b=="undefined")b=this.$node.data("mejsoptions");this.options=f.extend({},mejs.MepDefaults,b);this.id="mep_"+mejs.mepIndex++; |
||||
mejs.players[this.id]=this;this.init();return this};mejs.MediaElementPlayer.prototype={hasFocus:false,controlsAreVisible:true,init:function(){var a=this,b=mejs.MediaFeatures,c=f.extend(true,{},a.options,{success:function(d,g){a.meReady(d,g)},error:function(d){a.handleError(d)}}),e=a.media.tagName.toLowerCase();a.isDynamic=e!=="audio"&&e!=="video";a.isVideo=a.isDynamic?a.options.isVideo:e!=="audio"&&a.options.isVideo;if(b.isiPad&&a.options.iPadUseNativeControls||b.isiPhone&&a.options.iPhoneUseNativeControls){a.$media.attr("controls", |
||||
"controls");if(b.isiPad&&a.media.getAttribute("autoplay")!==null){a.media.load();a.media.play()}}else if(!(b.isAndroid&&a.options.AndroidUseNativeControls)){a.$media.removeAttr("controls");a.container=f('<div id="'+a.id+'" class="mejs-container '+(mejs.MediaFeatures.svg?"svg":"no-svg")+'"><div class="mejs-inner"><div class="mejs-mediaelement"></div><div class="mejs-layers"></div><div class="mejs-controls"></div><div class="mejs-clear"></div></div></div>').addClass(a.$media[0].className).insertBefore(a.$media); |
||||
a.container.addClass((b.isAndroid?"mejs-android ":"")+(b.isiOS?"mejs-ios ":"")+(b.isiPad?"mejs-ipad ":"")+(b.isiPhone?"mejs-iphone ":"")+(a.isVideo?"mejs-video ":"mejs-audio "));if(b.isiOS){b=a.$media.clone();a.container.find(".mejs-mediaelement").append(b);a.$media.remove();a.$node=a.$media=b;a.node=a.media=b[0]}else a.container.find(".mejs-mediaelement").append(a.$media);a.controls=a.container.find(".mejs-controls");a.layers=a.container.find(".mejs-layers");b=a.isVideo?"video":"audio";e=b.substring(0, |
||||
1).toUpperCase()+b.substring(1);a.width=a.options[b+"Width"]>0||a.options[b+"Width"].toString().indexOf("%")>-1?a.options[b+"Width"]:a.media.style.width!==""&&a.media.style.width!==null?a.media.style.width:a.media.getAttribute("width")!==null?a.$media.attr("width"):a.options["default"+e+"Width"];a.height=a.options[b+"Height"]>0||a.options[b+"Height"].toString().indexOf("%")>-1?a.options[b+"Height"]:a.media.style.height!==""&&a.media.style.height!==null?a.media.style.height:a.$media[0].getAttribute("height")!== |
||||
null?a.$media.attr("height"):a.options["default"+e+"Height"];a.setPlayerSize(a.width,a.height);c.pluginWidth=a.width;c.pluginHeight=a.height}mejs.MediaElement(a.$media[0],c);typeof a.container!="undefined"&&a.controlsAreVisible&&a.container.trigger("controlsshown")},showControls:function(a){var b=this;a=typeof a=="undefined"||a;if(!b.controlsAreVisible){if(a){b.controls.css("visibility","visible").stop(true,true).fadeIn(200,function(){b.controlsAreVisible=true;b.container.trigger("controlsshown")}); |
||||
b.container.find(".mejs-control").css("visibility","visible").stop(true,true).fadeIn(200,function(){b.controlsAreVisible=true})}else{b.controls.css("visibility","visible").css("display","block");b.container.find(".mejs-control").css("visibility","visible").css("display","block");b.controlsAreVisible=true;b.container.trigger("controlsshown")}b.setControlsSize()}},hideControls:function(a){var b=this;a=typeof a=="undefined"||a;if(!(!b.controlsAreVisible||b.options.alwaysShowControls))if(a){b.controls.stop(true, |
||||
true).fadeOut(200,function(){f(this).css("visibility","hidden").css("display","block");b.controlsAreVisible=false;b.container.trigger("controlshidden")});b.container.find(".mejs-control").stop(true,true).fadeOut(200,function(){f(this).css("visibility","hidden").css("display","block")})}else{b.controls.css("visibility","hidden").css("display","block");b.container.find(".mejs-control").css("visibility","hidden").css("display","block");b.controlsAreVisible=false;b.container.trigger("controlshidden")}}, |
||||
controlsTimer:null,startControlsTimer:function(a){var b=this;a=typeof a!="undefined"?a:1500;b.killControlsTimer("start");b.controlsTimer=setTimeout(function(){b.hideControls();b.killControlsTimer("hide")},a)},killControlsTimer:function(){if(this.controlsTimer!==null){clearTimeout(this.controlsTimer);delete this.controlsTimer;this.controlsTimer=null}},controlsEnabled:true,disableControls:function(){this.killControlsTimer();this.hideControls(false);this.controlsEnabled=false},enableControls:function(){this.showControls(false); |
||||
this.controlsEnabled=true},meReady:function(a,b){var c=this,e=mejs.MediaFeatures,d=b.getAttribute("autoplay");d=!(typeof d=="undefined"||d===null||d==="false");var g;if(!c.created){c.created=true;c.media=a;c.domNode=b;if(!(e.isAndroid&&c.options.AndroidUseNativeControls)&&!(e.isiPad&&c.options.iPadUseNativeControls)&&!(e.isiPhone&&c.options.iPhoneUseNativeControls)){c.buildposter(c,c.controls,c.layers,c.media);c.buildkeyboard(c,c.controls,c.layers,c.media);c.buildoverlays(c,c.controls,c.layers,c.media); |
||||
c.findTracks();for(g in c.options.features){e=c.options.features[g];if(c["build"+e])try{c["build"+e](c,c.controls,c.layers,c.media)}catch(k){}}c.container.trigger("controlsready");c.setPlayerSize(c.width,c.height);c.setControlsSize();if(c.isVideo){if(mejs.MediaFeatures.hasTouch)c.$media.bind("touchstart",function(){if(c.controlsAreVisible)c.hideControls(false);else c.controlsEnabled&&c.showControls(false)});else{mejs.MediaElementPlayer.prototype.clickToPlayPauseCallback=function(){if(c.options.clickToPlayPause)c.media.paused? |
||||
c.media.play():c.media.pause()};c.media.addEventListener("click",c.clickToPlayPauseCallback,false);c.container.bind("mouseenter mouseover",function(){if(c.controlsEnabled)if(!c.options.alwaysShowControls){c.killControlsTimer("enter");c.showControls();c.startControlsTimer(2500)}}).bind("mousemove",function(){if(c.controlsEnabled){c.controlsAreVisible||c.showControls();c.options.alwaysShowControls||c.startControlsTimer(2500)}}).bind("mouseleave",function(){c.controlsEnabled&&!c.media.paused&&!c.options.alwaysShowControls&& |
||||
c.startControlsTimer(1E3)})}c.options.hideVideoControlsOnLoad&&c.hideControls(false);d&&!c.options.alwaysShowControls&&c.hideControls();c.options.enableAutosize&&c.media.addEventListener("loadedmetadata",function(j){if(c.options.videoHeight<=0&&c.domNode.getAttribute("height")===null&&!isNaN(j.target.videoHeight)){c.setPlayerSize(j.target.videoWidth,j.target.videoHeight);c.setControlsSize();c.media.setVideoSize(j.target.videoWidth,j.target.videoHeight)}},false)}a.addEventListener("play",function(){for(var j in mejs.players){var m= |
||||
mejs.players[j];m.id!=c.id&&c.options.pauseOtherPlayers&&!m.paused&&!m.ended&&m.pause();m.hasFocus=false}c.hasFocus=true},false);c.media.addEventListener("ended",function(){if(c.options.autoRewind)try{c.media.setCurrentTime(0)}catch(j){}c.media.pause();c.setProgressRail&&c.setProgressRail();c.setCurrentRail&&c.setCurrentRail();if(c.options.loop)c.media.play();else!c.options.alwaysShowControls&&c.controlsEnabled&&c.showControls()},false);c.media.addEventListener("loadedmetadata",function(){c.updateDuration&& |
||||
c.updateDuration();c.updateCurrent&&c.updateCurrent();if(!c.isFullScreen){c.setPlayerSize(c.width,c.height);c.setControlsSize()}},false);setTimeout(function(){c.setPlayerSize(c.width,c.height);c.setControlsSize()},50);c.globalBind("resize",function(){c.isFullScreen||mejs.MediaFeatures.hasTrueNativeFullScreen&&document.webkitIsFullScreen||c.setPlayerSize(c.width,c.height);c.setControlsSize()});c.media.pluginType=="youtube"&&c.container.find(".mejs-overlay-play").hide()}if(d&&a.pluginType=="native"){a.load(); |
||||
a.play()}if(c.options.success)typeof c.options.success=="string"?window[c.options.success](c.media,c.domNode,c):c.options.success(c.media,c.domNode,c)}},handleError:function(a){this.controls.hide();this.options.error&&this.options.error(a)},setPlayerSize:function(a,b){if(typeof a!="undefined")this.width=a;if(typeof b!="undefined")this.height=b;if(this.height.toString().indexOf("%")>0||this.$node.css("max-width")==="100%"||parseInt(this.$node.css("max-width").replace(/px/,""),10)/this.$node.offsetParent().width()=== |
||||
1||this.$node[0].currentStyle&&this.$node[0].currentStyle.maxWidth==="100%"){var c=this.isVideo?this.media.videoWidth&&this.media.videoWidth>0?this.media.videoWidth:this.options.defaultVideoWidth:this.options.defaultAudioWidth,e=this.isVideo?this.media.videoHeight&&this.media.videoHeight>0?this.media.videoHeight:this.options.defaultVideoHeight:this.options.defaultAudioHeight,d=this.container.parent().closest(":visible").width();c=this.isVideo||!this.options.autosizeProgress?parseInt(d*e/c,10):e;if(this.container.parent()[0].tagName.toLowerCase()=== |
||||
"body"){d=f(window).width();c=f(window).height()}if(c!=0&&d!=0){this.container.width(d).height(c);this.$media.add(this.container.find(".mejs-shim")).width("100%").height("100%");this.isVideo&&this.media.setVideoSize&&this.media.setVideoSize(d,c);this.layers.children(".mejs-layer").width("100%").height("100%")}}else{this.container.width(this.width).height(this.height);this.layers.children(".mejs-layer").width(this.width).height(this.height)}d=this.layers.find(".mejs-overlay-play");c=d.find(".mejs-overlay-button"); |
||||
d.height(this.container.height()-this.controls.height());c.css("margin-top","-"+(c.height()/2-this.controls.height()/2).toString()+"px")},setControlsSize:function(){var a=0,b=0,c=this.controls.find(".mejs-time-rail"),e=this.controls.find(".mejs-time-total");this.controls.find(".mejs-time-current");this.controls.find(".mejs-time-loaded");var d=c.siblings();if(this.options&&!this.options.autosizeProgress)b=parseInt(c.css("width"));if(b===0||!b){d.each(function(){var g=f(this);if(g.css("position")!= |
||||
"absolute"&&g.is(":visible"))a+=f(this).outerWidth(true)});b=this.controls.width()-a-(c.outerWidth(true)-c.width())}c.width(b);e.width(b-(e.outerWidth(true)-e.width()));this.setProgressRail&&this.setProgressRail();this.setCurrentRail&&this.setCurrentRail()},buildposter:function(a,b,c,e){var d=f('<div class="mejs-poster mejs-layer"></div>').appendTo(c);b=a.$media.attr("poster");if(a.options.poster!=="")b=a.options.poster;b!==""&&b!=null?this.setPoster(b):d.hide();e.addEventListener("play",function(){d.hide()}, |
||||
false);a.options.showPosterWhenEnded&&a.options.autoRewind&&e.addEventListener("ended",function(){d.show()},false)},setPoster:function(a){var b=this.container.find(".mejs-poster"),c=b.find("img");if(c.length==0)c=f('<img width="100%" height="100%" />').appendTo(b);c.attr("src",a);b.css({"background-image":"url("+a+")"})},buildoverlays:function(a,b,c,e){var d=this;if(a.isVideo){var g=f('<div class="mejs-overlay mejs-layer"><div class="mejs-overlay-loading"><span></span></div></div>').hide().appendTo(c), |
||||
k=f('<div class="mejs-overlay mejs-layer"><div class="mejs-overlay-error"></div></div>').hide().appendTo(c),j=f('<div class="mejs-overlay mejs-layer mejs-overlay-play"><div class="mejs-overlay-button"></div></div>').appendTo(c).click(function(){if(d.options.clickToPlayPause)e.paused?e.play():e.pause()});e.addEventListener("play",function(){j.hide();g.hide();b.find(".mejs-time-buffering").hide();k.hide()},false);e.addEventListener("playing",function(){j.hide();g.hide();b.find(".mejs-time-buffering").hide(); |
||||
k.hide()},false);e.addEventListener("seeking",function(){g.show();b.find(".mejs-time-buffering").show()},false);e.addEventListener("seeked",function(){g.hide();b.find(".mejs-time-buffering").hide()},false);e.addEventListener("pause",function(){mejs.MediaFeatures.isiPhone||j.show()},false);e.addEventListener("waiting",function(){g.show();b.find(".mejs-time-buffering").show()},false);e.addEventListener("loadeddata",function(){g.show();b.find(".mejs-time-buffering").show()},false);e.addEventListener("canplay", |
||||
function(){g.hide();b.find(".mejs-time-buffering").hide()},false);e.addEventListener("error",function(){g.hide();b.find(".mejs-time-buffering").hide();k.show();k.find("mejs-overlay-error").html("Error loading this resource")},false)}},buildkeyboard:function(a,b,c,e){this.globalBind("keydown",function(d){if(a.hasFocus&&a.options.enableKeyboard)for(var g=0,k=a.options.keyActions.length;g<k;g++)for(var j=a.options.keyActions[g],m=0,q=j.keys.length;m<q;m++)if(d.keyCode==j.keys[m]){d.preventDefault(); |
||||
j.action(a,e,d.keyCode);return false}return true});this.globalBind("click",function(d){if(f(d.target).closest(".mejs-container").length==0)a.hasFocus=false})},findTracks:function(){var a=this,b=a.$media.find("track");a.tracks=[];b.each(function(c,e){e=f(e);a.tracks.push({srclang:e.attr("srclang")?e.attr("srclang").toLowerCase():"",src:e.attr("src"),kind:e.attr("kind"),label:e.attr("label")||"",entries:[],isLoaded:false})})},changeSkin:function(a){this.container[0].className="mejs-container "+a;this.setPlayerSize(this.width, |
||||
this.height);this.setControlsSize()},play:function(){this.media.play()},pause:function(){try{this.media.pause()}catch(a){}},load:function(){this.media.load()},setMuted:function(a){this.media.setMuted(a)},setCurrentTime:function(a){this.media.setCurrentTime(a)},getCurrentTime:function(){return this.media.currentTime},setVolume:function(a){this.media.setVolume(a)},getVolume:function(){return this.media.volume},setSrc:function(a){this.media.setSrc(a)},remove:function(){var a,b;for(a in this.options.features){b= |
||||
this.options.features[a];if(this["clean"+b])try{this["clean"+b](this)}catch(c){}}if(this.isDynamic)this.$node.insertBefore(this.container);else{this.$media.prop("controls",true);this.$node.clone().show().insertBefore(this.container);this.$node.remove()}this.media.pluginType!=="native"&&this.media.remove();delete mejs.players[this.id];this.container.remove();this.globalUnbind();delete this.node.player}};(function(){function a(c,e){var d={d:[],w:[]};f.each((c||"").split(" "),function(g,k){var j=k+"."+ |
||||
e;if(j.indexOf(".")===0){d.d.push(j);d.w.push(j)}else d[b.test(k)?"w":"d"].push(j)});d.d=d.d.join(" ");d.w=d.w.join(" ");return d}var b=/^((after|before)print|(before)?unload|hashchange|message|o(ff|n)line|page(hide|show)|popstate|resize|storage)\b/;mejs.MediaElementPlayer.prototype.globalBind=function(c,e,d){c=a(c,this.id);c.d&&f(document).bind(c.d,e,d);c.w&&f(window).bind(c.w,e,d)};mejs.MediaElementPlayer.prototype.globalUnbind=function(c,e){c=a(c,this.id);c.d&&f(document).unbind(c.d,e);c.w&&f(window).unbind(c.w, |
||||
e)}})();if(typeof jQuery!="undefined")jQuery.fn.mediaelementplayer=function(a){a===false?this.each(function(){var b=jQuery(this).data("mediaelementplayer");b&&b.remove();jQuery(this).removeData("mediaelementplayer")}):this.each(function(){jQuery(this).data("mediaelementplayer",new mejs.MediaElementPlayer(this,a))});return this};f(document).ready(function(){f(".mejs-player").mediaelementplayer()});window.MediaElementPlayer=mejs.MediaElementPlayer})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{playpauseText:mejs.i18n.t("Play/Pause")});f.extend(MediaElementPlayer.prototype,{buildplaypause:function(a,b,c,e){var d=f('<div class="mejs-button mejs-playpause-button mejs-play" ><button type="button" aria-controls="'+this.id+'" title="'+this.options.playpauseText+'" aria-label="'+this.options.playpauseText+'"></button></div>').appendTo(b).click(function(g){g.preventDefault();e.paused?e.play():e.pause();return false});e.addEventListener("play",function(){d.removeClass("mejs-play").addClass("mejs-pause")}, |
||||
false);e.addEventListener("playing",function(){d.removeClass("mejs-play").addClass("mejs-pause")},false);e.addEventListener("pause",function(){d.removeClass("mejs-pause").addClass("mejs-play")},false);e.addEventListener("paused",function(){d.removeClass("mejs-pause").addClass("mejs-play")},false)}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{stopText:"Stop"});f.extend(MediaElementPlayer.prototype,{buildstop:function(a,b,c,e){f('<div class="mejs-button mejs-stop-button mejs-stop"><button type="button" aria-controls="'+this.id+'" title="'+this.options.stopText+'" aria-label="'+this.options.stopText+'"></button></div>').appendTo(b).click(function(){e.paused||e.pause();if(e.currentTime>0){e.setCurrentTime(0);e.pause();b.find(".mejs-time-current").width("0px");b.find(".mejs-time-handle").css("left", |
||||
"0px");b.find(".mejs-time-float-current").html(mejs.Utility.secondsToTimeCode(0));b.find(".mejs-currenttime").html(mejs.Utility.secondsToTimeCode(0));c.find(".mejs-poster").show()}})}})})(mejs.$); |
||||
(function(f){f.extend(MediaElementPlayer.prototype,{buildprogress:function(a,b,c,e){f('<div class="mejs-time-rail"><span class="mejs-time-total"><span class="mejs-time-buffering"></span><span class="mejs-time-loaded"></span><span class="mejs-time-current"></span><span class="mejs-time-handle"></span><span class="mejs-time-float"><span class="mejs-time-float-current">00:00</span><span class="mejs-time-float-corner"></span></span></span></div>').appendTo(b);b.find(".mejs-time-buffering").hide();var d= |
||||
this,g=b.find(".mejs-time-total");c=b.find(".mejs-time-loaded");var k=b.find(".mejs-time-current"),j=b.find(".mejs-time-handle"),m=b.find(".mejs-time-float"),q=b.find(".mejs-time-float-current"),p=function(h){h=h.pageX;var l=g.offset(),r=g.outerWidth(true),n=0,o=n=0;if(e.duration){if(h<l.left)h=l.left;else if(h>r+l.left)h=r+l.left;o=h-l.left;n=o/r;n=n<=0.02?0:n*e.duration;t&&n!==e.currentTime&&e.setCurrentTime(n);if(!mejs.MediaFeatures.hasTouch){m.css("left",o);q.html(mejs.Utility.secondsToTimeCode(n)); |
||||
m.show()}}},t=false;g.bind("mousedown",function(h){if(h.which===1){t=true;p(h);d.globalBind("mousemove.dur",function(l){p(l)});d.globalBind("mouseup.dur",function(){t=false;m.hide();d.globalUnbind(".dur")});return false}}).bind("mouseenter",function(){d.globalBind("mousemove.dur",function(h){p(h)});mejs.MediaFeatures.hasTouch||m.show()}).bind("mouseleave",function(){if(!t){d.globalUnbind(".dur");m.hide()}});e.addEventListener("progress",function(h){a.setProgressRail(h);a.setCurrentRail(h)},false); |
||||
e.addEventListener("timeupdate",function(h){a.setProgressRail(h);a.setCurrentRail(h)},false);d.loaded=c;d.total=g;d.current=k;d.handle=j},setProgressRail:function(a){var b=a!=undefined?a.target:this.media,c=null;if(b&&b.buffered&&b.buffered.length>0&&b.buffered.end&&b.duration)c=b.buffered.end(0)/b.duration;else if(b&&b.bytesTotal!=undefined&&b.bytesTotal>0&&b.bufferedBytes!=undefined)c=b.bufferedBytes/b.bytesTotal;else if(a&&a.lengthComputable&&a.total!=0)c=a.loaded/a.total;if(c!==null){c=Math.min(1, |
||||
Math.max(0,c));this.loaded&&this.total&&this.loaded.width(this.total.width()*c)}},setCurrentRail:function(){if(this.media.currentTime!=undefined&&this.media.duration)if(this.total&&this.handle){var a=Math.round(this.total.width()*this.media.currentTime/this.media.duration),b=a-Math.round(this.handle.outerWidth(true)/2);this.current.width(a);this.handle.css("left",b)}}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{duration:-1,timeAndDurationSeparator:"<span> | </span>"});f.extend(MediaElementPlayer.prototype,{buildcurrent:function(a,b,c,e){f('<div class="mejs-time"><span class="mejs-currenttime">'+(a.options.alwaysShowHours?"00:":"")+(a.options.showTimecodeFrameCount?"00:00:00":"00:00")+"</span></div>").appendTo(b);this.currenttime=this.controls.find(".mejs-currenttime");e.addEventListener("timeupdate",function(){a.updateCurrent()},false)},buildduration:function(a,b, |
||||
c,e){if(b.children().last().find(".mejs-currenttime").length>0)f(this.options.timeAndDurationSeparator+'<span class="mejs-duration">'+(this.options.duration>0?mejs.Utility.secondsToTimeCode(this.options.duration,this.options.alwaysShowHours||this.media.duration>3600,this.options.showTimecodeFrameCount,this.options.framesPerSecond||25):(a.options.alwaysShowHours?"00:":"")+(a.options.showTimecodeFrameCount?"00:00:00":"00:00"))+"</span>").appendTo(b.find(".mejs-time"));else{b.find(".mejs-currenttime").parent().addClass("mejs-currenttime-container"); |
||||
f('<div class="mejs-time mejs-duration-container"><span class="mejs-duration">'+(this.options.duration>0?mejs.Utility.secondsToTimeCode(this.options.duration,this.options.alwaysShowHours||this.media.duration>3600,this.options.showTimecodeFrameCount,this.options.framesPerSecond||25):(a.options.alwaysShowHours?"00:":"")+(a.options.showTimecodeFrameCount?"00:00:00":"00:00"))+"</span></div>").appendTo(b)}this.durationD=this.controls.find(".mejs-duration");e.addEventListener("timeupdate",function(){a.updateDuration()}, |
||||
false)},updateCurrent:function(){if(this.currenttime)this.currenttime.html(mejs.Utility.secondsToTimeCode(this.media.currentTime,this.options.alwaysShowHours||this.media.duration>3600,this.options.showTimecodeFrameCount,this.options.framesPerSecond||25))},updateDuration:function(){this.container.toggleClass("mejs-long-video",this.media.duration>3600);if(this.durationD&&(this.options.duration>0||this.media.duration))this.durationD.html(mejs.Utility.secondsToTimeCode(this.options.duration>0?this.options.duration: |
||||
this.media.duration,this.options.alwaysShowHours,this.options.showTimecodeFrameCount,this.options.framesPerSecond||25))}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{muteText:mejs.i18n.t("Mute Toggle"),hideVolumeOnTouchDevices:true,audioVolume:"horizontal",videoVolume:"vertical"});f.extend(MediaElementPlayer.prototype,{buildvolume:function(a,b,c,e){if(!(mejs.MediaFeatures.hasTouch&&this.options.hideVolumeOnTouchDevices)){var d=this,g=d.isVideo?d.options.videoVolume:d.options.audioVolume,k=g=="horizontal"?f('<div class="mejs-button mejs-volume-button mejs-mute"><button type="button" aria-controls="'+d.id+'" title="'+d.options.muteText+ |
||||
'" aria-label="'+d.options.muteText+'"></button></div><div class="mejs-horizontal-volume-slider"><div class="mejs-horizontal-volume-total"></div><div class="mejs-horizontal-volume-current"></div><div class="mejs-horizontal-volume-handle"></div></div>').appendTo(b):f('<div class="mejs-button mejs-volume-button mejs-mute"><button type="button" aria-controls="'+d.id+'" title="'+d.options.muteText+'" aria-label="'+d.options.muteText+'"></button><div class="mejs-volume-slider"><div class="mejs-volume-total"></div><div class="mejs-volume-current"></div><div class="mejs-volume-handle"></div></div></div>').appendTo(b), |
||||
j=d.container.find(".mejs-volume-slider, .mejs-horizontal-volume-slider"),m=d.container.find(".mejs-volume-total, .mejs-horizontal-volume-total"),q=d.container.find(".mejs-volume-current, .mejs-horizontal-volume-current"),p=d.container.find(".mejs-volume-handle, .mejs-horizontal-volume-handle"),t=function(n,o){if(!j.is(":visible")&&typeof o=="undefined"){j.show();t(n,true);j.hide()}else{n=Math.max(0,n);n=Math.min(n,1);n==0?k.removeClass("mejs-mute").addClass("mejs-unmute"):k.removeClass("mejs-unmute").addClass("mejs-mute"); |
||||
if(g=="vertical"){var s=m.height(),u=m.position(),v=s-s*n;p.css("top",Math.round(u.top+v-p.height()/2));q.height(s-v);q.css("top",u.top+v)}else{s=m.width();u=m.position();s=s*n;p.css("left",Math.round(u.left+s-p.width()/2));q.width(Math.round(s))}}},h=function(n){var o=null,s=m.offset();if(g=="vertical"){o=m.height();parseInt(m.css("top").replace(/px/,""),10);o=(o-(n.pageY-s.top))/o;if(s.top==0||s.left==0)return}else{o=m.width();o=(n.pageX-s.left)/o}o=Math.max(0,o);o=Math.min(o,1);t(o);o==0?e.setMuted(true): |
||||
e.setMuted(false);e.setVolume(o)},l=false,r=false;k.hover(function(){j.show();r=true},function(){r=false;!l&&g=="vertical"&&j.hide()});j.bind("mouseover",function(){r=true}).bind("mousedown",function(n){h(n);d.globalBind("mousemove.vol",function(o){h(o)});d.globalBind("mouseup.vol",function(){l=false;d.globalUnbind(".vol");!r&&g=="vertical"&&j.hide()});l=true;return false});k.find("button").click(function(){e.setMuted(!e.muted)});e.addEventListener("volumechange",function(){if(!l)if(e.muted){t(0); |
||||
k.removeClass("mejs-mute").addClass("mejs-unmute")}else{t(e.volume);k.removeClass("mejs-unmute").addClass("mejs-mute")}},false);if(d.container.is(":visible")){t(a.options.startVolume);a.options.startVolume===0&&e.setMuted(true);e.pluginType==="native"&&e.setVolume(a.options.startVolume)}}}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{usePluginFullScreen:true,newWindowCallback:function(){return""},fullscreenText:mejs.i18n.t("Fullscreen")});f.extend(MediaElementPlayer.prototype,{isFullScreen:false,isNativeFullScreen:false,isInIframe:false,buildfullscreen:function(a,b,c,e){if(a.isVideo){a.isInIframe=window.location!=window.parent.location;if(mejs.MediaFeatures.hasTrueNativeFullScreen){c=function(){if(a.isFullScreen)if(mejs.MediaFeatures.isFullScreen()){a.isNativeFullScreen=true;a.setControlsSize()}else{a.isNativeFullScreen= |
||||
false;a.exitFullScreen()}};mejs.MediaFeatures.hasMozNativeFullScreen?a.globalBind(mejs.MediaFeatures.fullScreenEventName,c):a.container.bind(mejs.MediaFeatures.fullScreenEventName,c)}var d=this,g=f('<div class="mejs-button mejs-fullscreen-button"><button type="button" aria-controls="'+d.id+'" title="'+d.options.fullscreenText+'" aria-label="'+d.options.fullscreenText+'"></button></div>').appendTo(b);if(d.media.pluginType==="native"||!d.options.usePluginFullScreen&&!mejs.MediaFeatures.isFirefox)g.click(function(){mejs.MediaFeatures.hasTrueNativeFullScreen&& |
||||
mejs.MediaFeatures.isFullScreen()||a.isFullScreen?a.exitFullScreen():a.enterFullScreen()});else{var k=null;if(function(){var h=document.createElement("x"),l=document.documentElement,r=window.getComputedStyle;if(!("pointerEvents"in h.style))return false;h.style.pointerEvents="auto";h.style.pointerEvents="x";l.appendChild(h);r=r&&r(h,"").pointerEvents==="auto";l.removeChild(h);return!!r}()&&!mejs.MediaFeatures.isOpera){var j=false,m=function(){if(j){for(var h in q)q[h].hide();g.css("pointer-events", |
||||
"");d.controls.css("pointer-events","");d.media.removeEventListener("click",d.clickToPlayPauseCallback);j=false}},q={};b=["top","left","right","bottom"];var p,t=function(){var h=g.offset().left-d.container.offset().left,l=g.offset().top-d.container.offset().top,r=g.outerWidth(true),n=g.outerHeight(true),o=d.container.width(),s=d.container.height();for(p in q)q[p].css({position:"absolute",top:0,left:0});q.top.width(o).height(l);q.left.width(h).height(n).css({top:l});q.right.width(o-h-r).height(n).css({top:l, |
||||
left:h+r});q.bottom.width(o).height(s-n-l).css({top:l+n})};d.globalBind("resize",function(){t()});p=0;for(c=b.length;p<c;p++)q[b[p]]=f('<div class="mejs-fullscreen-hover" />').appendTo(d.container).mouseover(m).hide();g.on("mouseover",function(){if(!d.isFullScreen){var h=g.offset(),l=a.container.offset();e.positionFullscreenButton(h.left-l.left,h.top-l.top,false);g.css("pointer-events","none");d.controls.css("pointer-events","none");d.media.addEventListener("click",d.clickToPlayPauseCallback);for(p in q)q[p].show(); |
||||
t();j=true}});e.addEventListener("fullscreenchange",function(){d.isFullScreen=!d.isFullScreen;d.isFullScreen?d.media.removeEventListener("click",d.clickToPlayPauseCallback):d.media.addEventListener("click",d.clickToPlayPauseCallback);m()});d.globalBind("mousemove",function(h){if(j){var l=g.offset();if(h.pageY<l.top||h.pageY>l.top+g.outerHeight(true)||h.pageX<l.left||h.pageX>l.left+g.outerWidth(true)){g.css("pointer-events","");d.controls.css("pointer-events","");j=false}}})}else g.on("mouseover", |
||||
function(){if(k!==null){clearTimeout(k);delete k}var h=g.offset(),l=a.container.offset();e.positionFullscreenButton(h.left-l.left,h.top-l.top,true)}).on("mouseout",function(){if(k!==null){clearTimeout(k);delete k}k=setTimeout(function(){e.hideFullscreenButton()},1500)})}a.fullscreenBtn=g;d.globalBind("keydown",function(h){if((mejs.MediaFeatures.hasTrueNativeFullScreen&&mejs.MediaFeatures.isFullScreen()||d.isFullScreen)&&h.keyCode==27)a.exitFullScreen()})}},cleanfullscreen:function(a){a.exitFullScreen()}, |
||||
containerSizeTimeout:null,enterFullScreen:function(){var a=this;if(!(a.media.pluginType!=="native"&&(mejs.MediaFeatures.isFirefox||a.options.usePluginFullScreen))){f(document.documentElement).addClass("mejs-fullscreen");normalHeight=a.container.height();normalWidth=a.container.width();if(a.media.pluginType==="native")if(mejs.MediaFeatures.hasTrueNativeFullScreen){mejs.MediaFeatures.requestFullScreen(a.container[0]);a.isInIframe&&setTimeout(function c(){if(a.isNativeFullScreen)f(window).width()!== |
||||
screen.width?a.exitFullScreen():setTimeout(c,500)},500)}else if(mejs.MediaFeatures.hasSemiNativeFullScreen){a.media.webkitEnterFullscreen();return}if(a.isInIframe){var b=a.options.newWindowCallback(this);if(b!=="")if(mejs.MediaFeatures.hasTrueNativeFullScreen)setTimeout(function(){if(!a.isNativeFullScreen){a.pause();window.open(b,a.id,"top=0,left=0,width="+screen.availWidth+",height="+screen.availHeight+",resizable=yes,scrollbars=no,status=no,toolbar=no")}},250);else{a.pause();window.open(b,a.id, |
||||
"top=0,left=0,width="+screen.availWidth+",height="+screen.availHeight+",resizable=yes,scrollbars=no,status=no,toolbar=no");return}}a.container.addClass("mejs-container-fullscreen").width("100%").height("100%");a.containerSizeTimeout=setTimeout(function(){a.container.css({width:"100%",height:"100%"});a.setControlsSize()},500);if(a.media.pluginType==="native")a.$media.width("100%").height("100%");else{a.container.find(".mejs-shim").width("100%").height("100%");a.media.setVideoSize(f(window).width(), |
||||
f(window).height())}a.layers.children("div").width("100%").height("100%");a.fullscreenBtn&&a.fullscreenBtn.removeClass("mejs-fullscreen").addClass("mejs-unfullscreen");a.setControlsSize();a.isFullScreen=true}},exitFullScreen:function(){clearTimeout(this.containerSizeTimeout);if(this.media.pluginType!=="native"&&mejs.MediaFeatures.isFirefox)this.media.setFullscreen(false);else{if(mejs.MediaFeatures.hasTrueNativeFullScreen&&(mejs.MediaFeatures.isFullScreen()||this.isFullScreen))mejs.MediaFeatures.cancelFullScreen(); |
||||
f(document.documentElement).removeClass("mejs-fullscreen");this.container.removeClass("mejs-container-fullscreen").width(normalWidth).height(normalHeight);if(this.media.pluginType==="native")this.$media.width(normalWidth).height(normalHeight);else{this.container.find(".mejs-shim").width(normalWidth).height(normalHeight);this.media.setVideoSize(normalWidth,normalHeight)}this.layers.children("div").width(normalWidth).height(normalHeight);this.fullscreenBtn.removeClass("mejs-unfullscreen").addClass("mejs-fullscreen"); |
||||
this.setControlsSize();this.isFullScreen=false}}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{startLanguage:"",tracksText:mejs.i18n.t("Captions/Subtitles"),hideCaptionsButtonWhenEmpty:true,toggleCaptionsButtonWhenOnlyOne:false,slidesSelector:""});f.extend(MediaElementPlayer.prototype,{hasChapters:false,buildtracks:function(a,b,c,e){if(a.tracks.length!=0){var d;if(this.domNode.textTracks)for(d=this.domNode.textTracks.length-1;d>=0;d--)this.domNode.textTracks[d].mode="hidden";a.chapters=f('<div class="mejs-chapters mejs-layer"></div>').prependTo(c).hide();a.captions= |
||||
f('<div class="mejs-captions-layer mejs-layer"><div class="mejs-captions-position mejs-captions-position-hover"><span class="mejs-captions-text"></span></div></div>').prependTo(c).hide();a.captionsText=a.captions.find(".mejs-captions-text");a.captionsButton=f('<div class="mejs-button mejs-captions-button"><button type="button" aria-controls="'+this.id+'" title="'+this.options.tracksText+'" aria-label="'+this.options.tracksText+'"></button><div class="mejs-captions-selector"><ul><li><input type="radio" name="'+ |
||||
a.id+'_captions" id="'+a.id+'_captions_none" value="none" checked="checked" /><label for="'+a.id+'_captions_none">'+mejs.i18n.t("None")+"</label></li></ul></div></div>").appendTo(b);for(d=b=0;d<a.tracks.length;d++)a.tracks[d].kind=="subtitles"&&b++;this.options.toggleCaptionsButtonWhenOnlyOne&&b==1?a.captionsButton.on("click",function(){a.setTrack(a.selectedTrack==null?a.tracks[0].srclang:"none")}):a.captionsButton.hover(function(){f(this).find(".mejs-captions-selector").css("visibility","visible")}, |
||||
function(){f(this).find(".mejs-captions-selector").css("visibility","hidden")}).on("click","input[type=radio]",function(){lang=this.value;a.setTrack(lang)});a.options.alwaysShowControls?a.container.find(".mejs-captions-position").addClass("mejs-captions-position-hover"):a.container.bind("controlsshown",function(){a.container.find(".mejs-captions-position").addClass("mejs-captions-position-hover")}).bind("controlshidden",function(){e.paused||a.container.find(".mejs-captions-position").removeClass("mejs-captions-position-hover")}); |
||||
a.trackToLoad=-1;a.selectedTrack=null;a.isLoadingTrack=false;for(d=0;d<a.tracks.length;d++)a.tracks[d].kind=="subtitles"&&a.addTrackButton(a.tracks[d].srclang,a.tracks[d].label);a.loadNextTrack();e.addEventListener("timeupdate",function(){a.displayCaptions()},false);if(a.options.slidesSelector!=""){a.slidesContainer=f(a.options.slidesSelector);e.addEventListener("timeupdate",function(){a.displaySlides()},false)}e.addEventListener("loadedmetadata",function(){a.displayChapters()},false);a.container.hover(function(){if(a.hasChapters){a.chapters.css("visibility", |
||||
"visible");a.chapters.fadeIn(200).height(a.chapters.find(".mejs-chapter").outerHeight())}},function(){a.hasChapters&&!e.paused&&a.chapters.fadeOut(200,function(){f(this).css("visibility","hidden");f(this).css("display","block")})});a.node.getAttribute("autoplay")!==null&&a.chapters.css("visibility","hidden")}},setTrack:function(a){var b;if(a=="none"){this.selectedTrack=null;this.captionsButton.removeClass("mejs-captions-enabled")}else for(b=0;b<this.tracks.length;b++)if(this.tracks[b].srclang==a){this.selectedTrack== |
||||
null&&this.captionsButton.addClass("mejs-captions-enabled");this.selectedTrack=this.tracks[b];this.captions.attr("lang",this.selectedTrack.srclang);this.displayCaptions();break}},loadNextTrack:function(){this.trackToLoad++;if(this.trackToLoad<this.tracks.length){this.isLoadingTrack=true;this.loadTrack(this.trackToLoad)}else{this.isLoadingTrack=false;this.checkForTracks()}},loadTrack:function(a){var b=this,c=b.tracks[a];f.ajax({url:c.src,dataType:"text",success:function(e){c.entries=typeof e=="string"&& |
||||
/<tt\s+xml/ig.exec(e)?mejs.TrackFormatParser.dfxp.parse(e):mejs.TrackFormatParser.webvvt.parse(e);c.isLoaded=true;b.enableTrackButton(c.srclang,c.label);b.loadNextTrack();c.kind=="chapters"&&b.media.addEventListener("play",function(){b.media.duration>0&&b.displayChapters(c)},false);c.kind=="slides"&&b.setupSlides(c)},error:function(){b.loadNextTrack()}})},enableTrackButton:function(a,b){if(b==="")b=mejs.language.codes[a]||a;this.captionsButton.find("input[value="+a+"]").prop("disabled",false).siblings("label").html(b); |
||||
this.options.startLanguage==a&&f("#"+this.id+"_captions_"+a).click();this.adjustLanguageBox()},addTrackButton:function(a,b){if(b==="")b=mejs.language.codes[a]||a;this.captionsButton.find("ul").append(f('<li><input type="radio" name="'+this.id+'_captions" id="'+this.id+"_captions_"+a+'" value="'+a+'" disabled="disabled" /><label for="'+this.id+"_captions_"+a+'">'+b+" (loading)</label></li>"));this.adjustLanguageBox();this.container.find(".mejs-captions-translations option[value="+a+"]").remove()}, |
||||
adjustLanguageBox:function(){this.captionsButton.find(".mejs-captions-selector").height(this.captionsButton.find(".mejs-captions-selector ul").outerHeight(true)+this.captionsButton.find(".mejs-captions-translations").outerHeight(true))},checkForTracks:function(){var a=false;if(this.options.hideCaptionsButtonWhenEmpty){for(i=0;i<this.tracks.length;i++)if(this.tracks[i].kind=="subtitles"){a=true;break}if(!a){this.captionsButton.hide();this.setControlsSize()}}},displayCaptions:function(){if(typeof this.tracks!= |
||||
"undefined"){var a,b=this.selectedTrack;if(b!=null&&b.isLoaded)for(a=0;a<b.entries.times.length;a++)if(this.media.currentTime>=b.entries.times[a].start&&this.media.currentTime<=b.entries.times[a].stop){this.captionsText.html(b.entries.text[a]);this.captions.show().height(0);return}this.captions.hide()}},setupSlides:function(a){this.slides=a;this.slides.entries.imgs=[this.slides.entries.text.length];this.showSlide(0)},showSlide:function(a){if(!(typeof this.tracks=="undefined"||typeof this.slidesContainer== |
||||
"undefined")){var b=this,c=b.slides.entries.text[a],e=b.slides.entries.imgs[a];if(typeof e=="undefined"||typeof e.fadeIn=="undefined")b.slides.entries.imgs[a]=e=f('<img src="'+c+'">').on("load",function(){e.appendTo(b.slidesContainer).hide().fadeIn().siblings(":visible").fadeOut()});else!e.is(":visible")&&!e.is(":animated")&&e.fadeIn().siblings(":visible").fadeOut()}},displaySlides:function(){if(typeof this.slides!="undefined"){var a=this.slides,b;for(b=0;b<a.entries.times.length;b++)if(this.media.currentTime>= |
||||
a.entries.times[b].start&&this.media.currentTime<=a.entries.times[b].stop){this.showSlide(b);break}}},displayChapters:function(){var a;for(a=0;a<this.tracks.length;a++)if(this.tracks[a].kind=="chapters"&&this.tracks[a].isLoaded){this.drawChapters(this.tracks[a]);this.hasChapters=true;break}},drawChapters:function(a){var b=this,c,e,d=e=0;b.chapters.empty();for(c=0;c<a.entries.times.length;c++){e=a.entries.times[c].stop-a.entries.times[c].start;e=Math.floor(e/b.media.duration*100);if(e+d>100||c==a.entries.times.length- |
||||
1&&e+d<100)e=100-d;b.chapters.append(f('<div class="mejs-chapter" rel="'+a.entries.times[c].start+'" style="left: '+d.toString()+"%;width: "+e.toString()+'%;"><div class="mejs-chapter-block'+(c==a.entries.times.length-1?" mejs-chapter-block-last":"")+'"><span class="ch-title">'+a.entries.text[c]+'</span><span class="ch-time">'+mejs.Utility.secondsToTimeCode(a.entries.times[c].start)+"–"+mejs.Utility.secondsToTimeCode(a.entries.times[c].stop)+"</span></div></div>"));d+=e}b.chapters.find("div.mejs-chapter").click(function(){b.media.setCurrentTime(parseFloat(f(this).attr("rel"))); |
||||
b.media.paused&&b.media.play()});b.chapters.show()}});mejs.language={codes:{af:"Afrikaans",sq:"Albanian",ar:"Arabic",be:"Belarusian",bg:"Bulgarian",ca:"Catalan",zh:"Chinese","zh-cn":"Chinese Simplified","zh-tw":"Chinese Traditional",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch",en:"English",et:"Estonian",tl:"Filipino",fi:"Finnish",fr:"French",gl:"Galician",de:"German",el:"Greek",ht:"Haitian Creole",iw:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",ga:"Irish",it:"Italian",ja:"Japanese", |
||||
ko:"Korean",lv:"Latvian",lt:"Lithuanian",mk:"Macedonian",ms:"Malay",mt:"Maltese",no:"Norwegian",fa:"Persian",pl:"Polish",pt:"Portuguese",ro:"Romanian",ru:"Russian",sr:"Serbian",sk:"Slovak",sl:"Slovenian",es:"Spanish",sw:"Swahili",sv:"Swedish",tl:"Tagalog",th:"Thai",tr:"Turkish",uk:"Ukrainian",vi:"Vietnamese",cy:"Welsh",yi:"Yiddish"}};mejs.TrackFormatParser={webvvt:{pattern_identifier:/^([a-zA-z]+-)?[0-9]+$/,pattern_timecode:/^([0-9]{2}:[0-9]{2}:[0-9]{2}([,.][0-9]{1,3})?) --\> ([0-9]{2}:[0-9]{2}:[0-9]{2}([,.][0-9]{3})?)(.*)$/, |
||||
parse:function(a){var b=0;a=mejs.TrackFormatParser.split2(a,/\r?\n/);for(var c={text:[],times:[]},e,d;b<a.length;b++)if(this.pattern_identifier.exec(a[b])){b++;if((e=this.pattern_timecode.exec(a[b]))&&b<a.length){b++;d=a[b];for(b++;a[b]!==""&&b<a.length;){d=d+"\n"+a[b];b++}d=f.trim(d).replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig,"<a href='$1' target='_blank'>$1</a>");c.text.push(d);c.times.push({start:mejs.Utility.convertSMPTEtoSeconds(e[1])==0?0.2:mejs.Utility.convertSMPTEtoSeconds(e[1]), |
||||
stop:mejs.Utility.convertSMPTEtoSeconds(e[3]),settings:e[5]})}}return c}},dfxp:{parse:function(a){a=f(a).filter("tt");var b=0;b=a.children("div").eq(0);var c=b.find("p");b=a.find("#"+b.attr("style"));var e,d;a={text:[],times:[]};if(b.length){d=b.removeAttr("id").get(0).attributes;if(d.length){e={};for(b=0;b<d.length;b++)e[d[b].name.split(":")[1]]=d[b].value}}for(b=0;b<c.length;b++){var g;d={start:null,stop:null,style:null};if(c.eq(b).attr("begin"))d.start=mejs.Utility.convertSMPTEtoSeconds(c.eq(b).attr("begin")); |
||||
if(!d.start&&c.eq(b-1).attr("end"))d.start=mejs.Utility.convertSMPTEtoSeconds(c.eq(b-1).attr("end"));if(c.eq(b).attr("end"))d.stop=mejs.Utility.convertSMPTEtoSeconds(c.eq(b).attr("end"));if(!d.stop&&c.eq(b+1).attr("begin"))d.stop=mejs.Utility.convertSMPTEtoSeconds(c.eq(b+1).attr("begin"));if(e){g="";for(var k in e)g+=k+":"+e[k]+";"}if(g)d.style=g;if(d.start==0)d.start=0.2;a.times.push(d);d=f.trim(c.eq(b).html()).replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, |
||||
"<a href='$1' target='_blank'>$1</a>");a.text.push(d);if(a.times.start==0)a.times.start=2}return a}},split2:function(a,b){return a.split(b)}};if("x\n\ny".split(/\n/gi).length!=3)mejs.TrackFormatParser.split2=function(a,b){var c=[],e="",d;for(d=0;d<a.length;d++){e+=a.substring(d,d+1);if(b.test(e)){c.push(e.replace(b,""));e=""}}c.push(e);return c}})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{contextMenuItems:[{render:function(a){if(typeof a.enterFullScreen=="undefined")return null;return a.isFullScreen?mejs.i18n.t("Turn off Fullscreen"):mejs.i18n.t("Go Fullscreen")},click:function(a){a.isFullScreen?a.exitFullScreen():a.enterFullScreen()}},{render:function(a){return a.media.muted?mejs.i18n.t("Unmute"):mejs.i18n.t("Mute")},click:function(a){a.media.muted?a.setMuted(false):a.setMuted(true)}},{isSeparator:true},{render:function(){return mejs.i18n.t("Download Video")}, |
||||
click:function(a){window.location.href=a.media.currentSrc}}]});f.extend(MediaElementPlayer.prototype,{buildcontextmenu:function(a){a.contextMenu=f('<div class="mejs-contextmenu"></div>').appendTo(f("body")).hide();a.container.bind("contextmenu",function(b){if(a.isContextMenuEnabled){b.preventDefault();a.renderContextMenu(b.clientX-1,b.clientY-1);return false}});a.container.bind("click",function(){a.contextMenu.hide()});a.contextMenu.bind("mouseleave",function(){a.startContextMenuTimer()})},cleancontextmenu:function(a){a.contextMenu.remove()}, |
||||
isContextMenuEnabled:true,enableContextMenu:function(){this.isContextMenuEnabled=true},disableContextMenu:function(){this.isContextMenuEnabled=false},contextMenuTimeout:null,startContextMenuTimer:function(){var a=this;a.killContextMenuTimer();a.contextMenuTimer=setTimeout(function(){a.hideContextMenu();a.killContextMenuTimer()},750)},killContextMenuTimer:function(){var a=this.contextMenuTimer;if(a!=null){clearTimeout(a);delete a}},hideContextMenu:function(){this.contextMenu.hide()},renderContextMenu:function(a, |
||||
b){for(var c=this,e="",d=c.options.contextMenuItems,g=0,k=d.length;g<k;g++)if(d[g].isSeparator)e+='<div class="mejs-contextmenu-separator"></div>';else{var j=d[g].render(c);if(j!=null)e+='<div class="mejs-contextmenu-item" data-itemindex="'+g+'" id="element-'+Math.random()*1E6+'">'+j+"</div>"}c.contextMenu.empty().append(f(e)).css({top:b,left:a}).show();c.contextMenu.find(".mejs-contextmenu-item").each(function(){var m=f(this),q=parseInt(m.data("itemindex"),10),p=c.options.contextMenuItems[q];typeof p.show!= |
||||
"undefined"&&p.show(m,c);m.click(function(){typeof p.click!="undefined"&&p.click(c);c.contextMenu.hide()})});setTimeout(function(){c.killControlsTimer("rev3")},100)}})})(mejs.$); |
||||
(function(f){f.extend(mejs.MepDefaults,{postrollCloseText:mejs.i18n.t("Close")});f.extend(MediaElementPlayer.prototype,{buildpostroll:function(a,b,c){var e=this.container.find('link[rel="postroll"]').attr("href");if(typeof e!=="undefined"){a.postroll=f('<div class="mejs-postroll-layer mejs-layer"><a class="mejs-postroll-close" onclick="$(this).parent().hide();return false;">'+this.options.postrollCloseText+'</a><div class="mejs-postroll-layer-content"></div></div>').prependTo(c).hide();this.media.addEventListener("ended", |
||||
function(){f.ajax({dataType:"html",url:e,success:function(d){c.find(".mejs-postroll-layer-content").html(d)}});a.postroll.show()},false)}}})})(mejs.$); |
||||
@ -0,0 +1,289 @@ |
||||
/* TED player */ |
||||
.mejs-container.mejs-ted { |
||||
|
||||
} |
||||
.mejs-ted .mejs-controls { |
||||
background: #eee; |
||||
height: 65px; |
||||
} |
||||
|
||||
.mejs-ted .mejs-button, |
||||
.mejs-ted .mejs-time { |
||||
position: absolute; |
||||
background: #ddd; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-time-rail .mejs-time-total { |
||||
background-color: none; |
||||
background: url(controls-ted.png) repeat-x 0 -52px; |
||||
height: 6px; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-time-rail .mejs-time-buffering { |
||||
height: 6px; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-time-rail .mejs-time-loaded { |
||||
background-color: none; |
||||
background: url(controls-ted.png) repeat-x 0 -52px; |
||||
width: 0; |
||||
height: 6px; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-time-rail .mejs-time-current { |
||||
width: 0; |
||||
height: 6px; |
||||
background-color: none; |
||||
background: url(controls-ted.png) repeat-x 0 -59px; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-time-rail .mejs-time-handle { |
||||
display: block; |
||||
margin: 0; |
||||
width: 14px; |
||||
height: 21px; |
||||
top: -7px; |
||||
border: 0; |
||||
background: url(controls-ted.png) no-repeat 0 0; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-time-rail .mejs-time-float { |
||||
display: none; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-playpause-button { |
||||
top: 29px; |
||||
left: 9px; |
||||
width: 49px; |
||||
height: 28px; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-playpause-button button { |
||||
width: 49px; |
||||
height: 28px; |
||||
background: url(controls-ted.png) no-repeat -50px -23px; |
||||
margin: 0; |
||||
padding: 0; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-pause button { |
||||
background-position: 0 -23px; |
||||
} |
||||
|
||||
.mejs-ted .mejs-controls .mejs-fullscreen-button { |
||||
top: 34px; |
||||
right: 9px; |
||||
width: 17px; |
||||
height: 15px; |
||||
background : none; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-fullscreen-button button { |
||||
width: 19px; |
||||
height: 17px; |
||||
background: transparent url(controls-ted.png) no-repeat 0 -66px; |
||||
margin: 0; |
||||
padding: 0; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-unfullscreen button { |
||||
background: transparent url(controls-ted.png) no-repeat -21px -66px; |
||||
margin: 0; |
||||
padding: 0; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-volume-button { |
||||
top: 30px; |
||||
right: 35px; |
||||
width: 24px; |
||||
height: 22px; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-mute button { |
||||
background: url(controls-ted.png) no-repeat -15px 0; |
||||
width: 24px; |
||||
height: 22px; |
||||
margin: 0; |
||||
padding: 0; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-unmute button { |
||||
background: url(controls-ted.png) no-repeat -40px 0; |
||||
width: 24px; |
||||
height: 22px; |
||||
margin: 0; |
||||
padding: 0; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-volume-button .mejs-volume-slider { |
||||
background: #fff; |
||||
border: solid 1px #aaa; |
||||
border-width: 1px 1px 0 1px; |
||||
width: 22px; |
||||
height: 65px; |
||||
top: -65px; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-volume-button .mejs-volume-total { |
||||
background: url(controls-ted.png) repeat-y -41px -66px; |
||||
left: 8px; |
||||
width: 6px; |
||||
height: 50px; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-volume-button .mejs-volume-current { |
||||
left: 8px; |
||||
width: 6px; |
||||
background: url(controls-ted.png) repeat-y -48px -66px; |
||||
height: 50px; |
||||
} |
||||
|
||||
.mejs-ted .mejs-controls .mejs-volume-button .mejs-volume-handle { |
||||
display: none; |
||||
} |
||||
|
||||
.mejs-ted .mejs-controls .mejs-time span { |
||||
color: #333; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-currenttime-container { |
||||
position: absolute; |
||||
top: 32px; |
||||
right: 100px; |
||||
border: solid 1px #999; |
||||
background: #fff; |
||||
color: #333; |
||||
padding-top: 2px; |
||||
border-radius: 3px; |
||||
color: #333; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-duration-container { |
||||
|
||||
position: absolute; |
||||
top: 32px; |
||||
right: 65px; |
||||
border: solid 1px #999; |
||||
background: #fff; |
||||
color: #333; |
||||
padding-top: 2px; |
||||
border-radius: 3px; |
||||
color: #333; |
||||
} |
||||
|
||||
.mejs-ted .mejs-controls .mejs-time button{ |
||||
color: #333; |
||||
} |
||||
.mejs-ted .mejs-controls .mejs-captions-button { |
||||
display: none; |
||||
} |
||||
/* END: TED player */ |
||||
|
||||
|
||||
/* WMP player */ |
||||
.mejs-container.mejs-wmp { |
||||
|
||||
} |
||||
.mejs-wmp .mejs-controls { |
||||
background: transparent url(controls-wmp-bg.png) center 16px no-repeat; |
||||
height: 65px; |
||||
} |
||||
|
||||
.mejs-wmp .mejs-button, |
||||
.mejs-wmp .mejs-time { |
||||
position: absolute; |
||||
background: transparent; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-time-rail .mejs-time-total { |
||||
background-color: transparent; |
||||
border: solid 1px #ccc; |
||||
height: 3px; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-time-rail .mejs-time-buffering { |
||||
height: 3px; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-time-rail .mejs-time-loaded { |
||||
background-color: rgba(255,255,255,0.3); |
||||
width: 0; |
||||
height: 3px; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-time-rail .mejs-time-current { |
||||
width: 0; |
||||
height: 1px; |
||||
background-color: #014CB6; |
||||
border: solid 1px #7FC9FA; |
||||
border-width: 1px 0; |
||||
border-color: #7FC9FA #fff #619FF2 #fff; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-time-rail .mejs-time-handle { |
||||
display: block; |
||||
margin: 0; |
||||
width: 16px; |
||||
height: 9px; |
||||
top: -3px; |
||||
border: 0; |
||||
background: url(controls-wmp.png) no-repeat 0 -80px; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-time-rail .mejs-time-float { |
||||
display: none; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-playpause-button { |
||||
top: 10px; |
||||
left: 50%; |
||||
margin: 10px 0 0 -20px; |
||||
width: 40px; |
||||
height: 40px; |
||||
|
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-playpause-button button { |
||||
width: 40px; |
||||
height: 40px; |
||||
background: url(controls-wmp.png) no-repeat 0 0; |
||||
margin: 0; |
||||
padding: 0; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-pause button { |
||||
background-position: 0 -40px; |
||||
} |
||||
|
||||
.mejs-wmp .mejs-controls .mejs-currenttime-container { |
||||
position: absolute; |
||||
top: 25px; |
||||
left: 50%; |
||||
margin-left: -93px; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-duration-container { |
||||
position: absolute; |
||||
top: 25px; |
||||
left: 50%; |
||||
margin-left: -58px; |
||||
} |
||||
|
||||
|
||||
.mejs-wmp .mejs-controls .mejs-volume-button { |
||||
top: 32px; |
||||
right: 50%; |
||||
margin-right: -55px; |
||||
width: 20px; |
||||
height: 15px; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-volume-button button { |
||||
margin: 0; |
||||
padding: 0; |
||||
background: url(controls-wmp.png) no-repeat -42px -17px; |
||||
width: 20px; |
||||
height: 15px; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-unmute button { |
||||
margin: 0; |
||||
padding: 0; |
||||
background: url(controls-wmp.png) no-repeat -42px 0; |
||||
width: 20px; |
||||
height: 15px; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-volume-button .mejs-volume-slider { |
||||
background: rgba(102,102,102,0.6); |
||||
} |
||||
|
||||
.mejs-wmp .mejs-controls .mejs-fullscreen-button { |
||||
top: 32px; |
||||
right: 50%; |
||||
margin-right: -82px; |
||||
width: 15px; |
||||
height: 14px; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-fullscreen-button button { |
||||
margin: 0; |
||||
padding: 0; |
||||
background: url(controls-wmp.png) no-repeat -63px 0; |
||||
width: 15px; |
||||
height: 14px; |
||||
} |
||||
.mejs-wmp .mejs-controls .mejs-captions-button { |
||||
display: none; |
||||
} |
||||
/* END: WMP player */ |
||||
|
||||
|
||||
|
||||
@ -0,0 +1,101 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* Class lp_item |
||||
* made to manipulate datas of lp_item table |
||||
* |
||||
* This class is still incomplte |
||||
* You can add lp_item database manipulation function here |
||||
* |
||||
*/ |
||||
|
||||
|
||||
class LpItem { |
||||
public $c_id=0; |
||||
public $id=0; |
||||
public $lp_id=0; |
||||
public $item_type=""; |
||||
public $ref=""; |
||||
public $title=""; |
||||
public $description=""; |
||||
public $path=""; |
||||
public $min_score=0; |
||||
public $max_score=0; |
||||
public $mastery_score=0; |
||||
public $parent_item_id=0; |
||||
public $previous_item_id=0; |
||||
public $next_item_id=0; |
||||
public $display_order=0; |
||||
public $prerequisite=""; |
||||
public $parameters=""; |
||||
public $launch_data=""; |
||||
public $max_time_allowed=""; |
||||
public $terms=""; |
||||
public $search_did=0; |
||||
public $audio=""; |
||||
|
||||
public function __construct($in_c_id=0, $in_id=0) { |
||||
if ($in_c_id > 0 && $in_id >0) { |
||||
$item_view_table = Database::get_course_table(TABLE_LP_ITEM); |
||||
$sql = "SELECT * FROM $item_view_table WHERE c_id=".Database::escape_string($in_c_id)." |
||||
AND id=".Database::escape_string($in_id); |
||||
|
||||
$res = Database::query($sql); |
||||
$data = Database::fetch_array($res); |
||||
if (Database::num_rows($res) > 0) { |
||||
$this->c_id = $data['c_id']; |
||||
$this->id = $data['id']; |
||||
$this->lp_id = $data['lp_id']; |
||||
$this->item_type = $data['item_type']; |
||||
$this->ref = $data['ref']; |
||||
$this->title = $data['title']; |
||||
$this->description = $data['description']; |
||||
$this->path = $data['path']; |
||||
$this->min_score = $data['min_score']; |
||||
$this->max_score = $data['max_score']; |
||||
$this->mastery_score = $data['mastery_score']; |
||||
$this->parent_item_id = $data['parent_item_id']; |
||||
$this->previous_item_id = $data['previous_item_id']; |
||||
$this->next_item_id = $data['next_item_id']; |
||||
$this->display_order = $data['display_order']; |
||||
$this->prerequisite = $data['prerequisite']; |
||||
$this->parameters = $data['parameters']; |
||||
$this->launch_data = $data['launch_data']; |
||||
$this->max_time_allowed = $data['max_time_allowed']; |
||||
$this->terms = $data['terms']; |
||||
$this->search_did = $data['search_did']; |
||||
$this->audio = $data['audio']; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public function update_in_bdd() { |
||||
$item_view_table = Database::get_course_table(TABLE_LP_ITEM); |
||||
if ($this->c_id > 0 && $this->id > 0) { |
||||
$sql = "UPDATE $item_view_table SET |
||||
lp_id = '".Database::escape_string($this->lp_id)."' , |
||||
item_type = '".Database::escape_string($this->item_type)."' , |
||||
ref = '".Database::escape_string($this->ref)."' , |
||||
title = '".Database::escape_string($this->title)."' , |
||||
description = '".Database::escape_string($this->description)."' , |
||||
path = '".Database::escape_string($this->path)."' , |
||||
min_score = '".Database::escape_string($this->min_score)."' , |
||||
max_score = '".Database::escape_string($this->max_score)."' , |
||||
mastery_score = '".Database::escape_string($this->mastery_score)."' , |
||||
parent_item_id = '".Database::escape_string($this->parent_item_id)."' , |
||||
previous_item_id = '".Database::escape_string($this->previous_item_id)."' , |
||||
next_item_id = '".Database::escape_string($this->next_item_id)."' , |
||||
display_order = '".Database::escape_string($this->display_order)."' , |
||||
prerequisite = '".Database::escape_string($this->prerequisite)."' , |
||||
parameters = '".Database::escape_string($this->parameters)."' , |
||||
launch_data = '".Database::escape_string($this->launch_data)."' , |
||||
max_time_allowed = '".Database::escape_string($this->max_time_allowed)."' , |
||||
terms = '".Database::escape_string($this->terms)."' , |
||||
search_did = '".Database::escape_string($this->search_did)."' , |
||||
audio = '".Database::escape_string($this->audio)."' |
||||
WHERE c_id=".$this->c_id." AND id=".$this->id; |
||||
Database::query($sql); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1 @@ |
||||
{{ content }} |
||||
@ -0,0 +1,188 @@ |
||||
<script type="text/javascript" src="{{ _p.web_lib }}javascript/rtc/RecordRTC.js"></script> |
||||
|
||||
<script type="text/javascript" src="{{ _p.web_lib }}swfobject/swfobject.js"></script> |
||||
<script type="text/javascript" src="{{ _p.web_lib }}wami-recorder/recorder.js"></script> |
||||
<script type="text/javascript" src="{{ _p.web_lib }}wami-recorder/gui.js"></script> |
||||
|
||||
<div id="rtc"> |
||||
<audio class="skip" id="audio" autoplay="" loop="" controls=""></audio> |
||||
<span id="progress-info"></span> |
||||
<br /> |
||||
<a id="record" class="btn btn-danger" >{{ 'RecordAudio' | get_lang }}</a> |
||||
<button id="stop" class="btn" disabled="">{{ 'StopRecordingAudio' | get_lang }}</button> |
||||
</div> |
||||
|
||||
<div id="wami" style="float:left"> |
||||
<a id="record-wami" class="btn btn-info">{{ 'ActivateAudioRecorder' | get_lang }}</a> |
||||
<br /> |
||||
<div id="wami-recorder"> |
||||
</div> |
||||
<div id="start-recording" class="alert" style="display:none"> |
||||
{{ "StartSpeaking" | get_lang }} |
||||
</div> |
||||
</div> |
||||
|
||||
<script> |
||||
|
||||
function setupRecorder() { |
||||
Wami.setup({ |
||||
id : "wami", |
||||
onReady : setupGUI, |
||||
swfUrl : "{{ _p.web_lib }}wami-recorder/Wami.swf" |
||||
}); |
||||
$('#wami-recorder').css('margin-bottom', '150px'); |
||||
} |
||||
|
||||
function setupGUI() { |
||||
var uniq = 'rec_' + (new Date()).getTime() + ".wav"; |
||||
var gui = new Wami.GUI({ |
||||
id : "wami-recorder", |
||||
recordUrl : "{{ _p.web_lib }}wami-recorder/record_document.php?lp_item_id={{ lp_item_id }}&waminame="+uniq+"&wamidir={{ lp_dir }}&wamiuserid={{ _u.user_id }}", |
||||
//playUrl : "https://wami-recorder.appspot.com/audio", |
||||
buttonUrl : "{{ _p.web_lib }}wami-recorder/buttons.png", |
||||
buttonNoUrl: "{{ _p.web_img }}blank.gif", |
||||
onRecordStart : function() { |
||||
//console.log('Record starts'); |
||||
$('#start-recording').show(); |
||||
}, |
||||
onRecordFinish: function() { |
||||
$('#start-recording').hide(); |
||||
window.location.reload(); |
||||
}, |
||||
onError : function() { |
||||
}, |
||||
singleButton : true |
||||
}); |
||||
|
||||
gui.setPlayEnabled(false); |
||||
} |
||||
</script> |
||||
<script> |
||||
|
||||
$(document).ready(function() { |
||||
var isChrome = navigator.webkitGetUserMedia; |
||||
//isChrome = false; |
||||
if (isChrome) { |
||||
$('#rtc').show(); |
||||
$('#wami').hide(); |
||||
} else { |
||||
$('#rtc').hide(); |
||||
$('#wami').show(); |
||||
|
||||
var recordWami = $('#record-wami'); |
||||
recordWami.on('click', function() { |
||||
setupRecorder(); |
||||
return false; |
||||
}); |
||||
} |
||||
|
||||
var format = 'webm'; // or wav |
||||
var record = $('#record'); |
||||
var stop = document.getElementById('stop'); |
||||
var preview = document.getElementById('audio'); |
||||
var progressInfo = document.getElementById('progress-info'); |
||||
var previewBlock = document.getElementById('preview'); |
||||
|
||||
function postBlob(blob, fileType, fileName) { |
||||
// FormData |
||||
var formData = new FormData(); |
||||
formData.append(fileType + '-filename', fileName); |
||||
formData.append(fileType + '-blob', blob); |
||||
|
||||
// progress-bar |
||||
var hr = document.createElement('hr'); |
||||
progressInfo.appendChild(hr); |
||||
var strong = document.createElement('strong'); |
||||
strong.innerHTML = fileType + ' upload progress: '; |
||||
progressInfo.appendChild(strong); |
||||
var progress = document.createElement('progress'); |
||||
progressInfo.appendChild(progress); |
||||
|
||||
// POST the Blob |
||||
|
||||
$.ajax({ |
||||
url:'{{ _p.web_ajax }}lp.ajax.php?a=record_audio&lp_item_id={{ lp_item_id }}', |
||||
data: formData, |
||||
processData: false, |
||||
contentType: false, |
||||
type: 'POST', |
||||
success:function(fileURL) { |
||||
|
||||
window.location.reload(); |
||||
|
||||
progressInfo.appendChild(document.createElement('hr')); |
||||
|
||||
var mediaElement = document.createElement(fileType); |
||||
mediaElement.src = fileURL; |
||||
mediaElement.controls = true; |
||||
var uniq = 'id' + (new Date()).getTime(); |
||||
mediaElement.id = uniq; |
||||
$(previewBlock).html(''); |
||||
|
||||
previewBlock.appendChild(mediaElement); |
||||
mediaElement.play(); |
||||
$(progressInfo).html(''); |
||||
window.location.reload(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
var recordAudio, recordVideo; |
||||
|
||||
record.on('click', function() { |
||||
|
||||
record.disabled = true; |
||||
|
||||
var myURL = (window.URL || window.webkitURL || {}); |
||||
|
||||
|
||||
if (navigator.getUserMedia) { |
||||
|
||||
navigator.getUserMedia({ |
||||
audio: true, |
||||
video: false |
||||
}, |
||||
function(stream) { |
||||
if (window.IsChrome) stream = new window.MediaStream(stream.getAudioTracks()); |
||||
|
||||
preview.src = myURL.createObjectURL(stream); |
||||
console.log(preview.src); |
||||
preview.play(); |
||||
|
||||
recordAudio = RecordRTC(stream, { |
||||
type: 'audio' |
||||
}); |
||||
recordAudio.startRecording(); |
||||
|
||||
/*recordVideo = RecordRTC(stream, { |
||||
type: 'video' |
||||
});*/ |
||||
//recordVideo.startRecording(); |
||||
stop.disabled = false; |
||||
}, |
||||
function(err) { |
||||
console.log("The following error occured: " + err); |
||||
return false; |
||||
}); |
||||
} |
||||
|
||||
}); |
||||
|
||||
stop.onclick = function() { |
||||
record.disabled = false; |
||||
stop.disabled = true; |
||||
|
||||
var fileName = Math.round(Math.random() * 99999999) + 99999999; |
||||
|
||||
recordAudio.stopRecording(); |
||||
|
||||
postBlob(recordAudio.getBlob(), 'audio', fileName + '.' + format); |
||||
|
||||
//recordVideo.stopRecording(); |
||||
//PostBlob(recordVideo.getBlob(), 'video', fileName + '.webm'); |
||||
|
||||
preview.src = ''; |
||||
}; |
||||
}); |
||||
|
||||
</script> |
||||
@ -0,0 +1,129 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
use ChamiloSession as Session; |
||||
|
||||
$language_file = array('exercice', 'work', 'document', 'admin', 'gradebook'); |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
// Including necessary files |
||||
require_once 'work.lib.php'; |
||||
|
||||
if (ADD_DOCUMENT_TO_WORK == false) { |
||||
exit; |
||||
} |
||||
|
||||
$current_course_tool = TOOL_STUDENTPUBLICATION; |
||||
|
||||
$workId = isset($_GET['id']) ? intval($_GET['id']) : null; |
||||
$docId = isset($_GET['document_id']) ? intval($_GET['document_id']) : null; |
||||
$action = isset($_GET['action']) ? $_GET['action'] : null; |
||||
|
||||
if (empty($workId)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$my_folder_data = get_work_data_by_id($workId); |
||||
if (empty($my_folder_data)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$work_data = get_work_assignment_by_id($workId); |
||||
|
||||
if (!api_is_allowed_to_edit()) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$courseInfo = api_get_course_info(); |
||||
|
||||
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications')); |
||||
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId, 'name' => $my_folder_data['title']); |
||||
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AddDocument')); |
||||
|
||||
$error_message = null; |
||||
|
||||
switch ($action) { |
||||
case 'delete': |
||||
if (!empty($workId) && !empty($docId)) { |
||||
deleteDocumentToWork($docId, $workId, api_get_course_int_id()); |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId; |
||||
header('Location: '.$url); |
||||
exit; |
||||
} |
||||
break; |
||||
} |
||||
|
||||
Display :: display_header(null); |
||||
|
||||
if (empty($docId)) { |
||||
echo Display::page_subheader(get_lang('DocumentsAdded')); |
||||
|
||||
$documents = getAllDocumentToWork($workId, api_get_course_int_id()); |
||||
if (!empty($documents)) { |
||||
echo '<div class="well">'; |
||||
foreach ($documents as $doc) { |
||||
$documentId = $doc['document_id']; |
||||
$docData = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']); |
||||
if ($docData) { |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_document.php?action=delete&id='.$workId.'&document_id='.$documentId; |
||||
$link = Display::url(get_lang('Delete'), $url); |
||||
echo $docData['title'].' '.$link.'<br />'; |
||||
} |
||||
|
||||
} |
||||
echo '</div>'; |
||||
} |
||||
|
||||
$document_tree = DocumentManager::get_document_preview($courseInfo, null, null, 0, false, '/', api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId); |
||||
echo Display::page_subheader(get_lang('DocumentToAdd')); |
||||
echo $document_tree; |
||||
echo '<hr /><div class="clear"></div>'; |
||||
|
||||
} else { |
||||
|
||||
$documentInfo = DocumentManager::get_document_data_by_id($docId, $courseInfo['code']); |
||||
$form = new FormValidator('add_doc', 'post', api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&document_id='.$docId); |
||||
$form->addElement('header', get_lang('AddDocument')); |
||||
$form->addElement('hidden', 'add_doc', '1'); |
||||
$form->addElement('hidden', 'id', $workId); |
||||
$form->addElement('hidden', 'document_id', $docId); |
||||
$form->addElement('label', get_lang('File'), $documentInfo['title']); |
||||
$form->addElement('style_submit_button', 'submit', get_lang('Add')); |
||||
$form->display(); |
||||
|
||||
if ($form->validate()) { |
||||
$values = $form->exportValues(); |
||||
$workId = $values['id']; |
||||
$docId = $values['document_id']; |
||||
$data = getDocumentToWork($docId, $workId, api_get_course_int_id()); |
||||
|
||||
if (empty($data)) { |
||||
addDocumentToWork($docId, $workId, api_get_course_int_id()); |
||||
Display::display_confirmation_message(get_lang('Added')); |
||||
} else { |
||||
Display::display_warning_message(get_lang('DocumentAlreadyAdded')); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* |
||||
CREATE TABLE IF NOT EXISTS c_student_publication_rel_document ( |
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, |
||||
work_id INT NOT NULL, |
||||
document_id INT NOT NULL, |
||||
c_id INT NOT NULL |
||||
); |
||||
|
||||
CREATE TABLE IF NOT EXISTS c_student_publication_rel_user ( |
||||
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, |
||||
work_id INT NOT NULL, |
||||
user_id INT NOT NULL, |
||||
c_id INT NOT NULL |
||||
); |
||||
|
||||
|
||||
|
||||
*/ |
||||
|
||||
|
||||
@ -0,0 +1,104 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
use ChamiloSession as Session; |
||||
|
||||
$language_file = array('exercice', 'work', 'document', 'admin', 'gradebook'); |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
// Including necessary files |
||||
require_once 'work.lib.php'; |
||||
|
||||
if (ADD_DOCUMENT_TO_WORK == false) { |
||||
exit; |
||||
} |
||||
|
||||
$current_course_tool = TOOL_STUDENTPUBLICATION; |
||||
|
||||
$workId = isset($_GET['id']) ? intval($_GET['id']) : null; |
||||
$userId = isset($_GET['user_id']) ? intval($_GET['user_id']) : null; |
||||
$action = isset($_GET['action']) ? $_GET['action'] : null; |
||||
|
||||
if (empty($workId)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$my_folder_data = get_work_data_by_id($workId); |
||||
if (empty($my_folder_data)) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$work_data = get_work_assignment_by_id($workId); |
||||
|
||||
if (!api_is_allowed_to_edit()) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$courseInfo = api_get_course_info(); |
||||
|
||||
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications')); |
||||
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId, 'name' => $my_folder_data['title']); |
||||
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AddUser')); |
||||
|
||||
$error_message = null; |
||||
|
||||
switch ($action) { |
||||
case 'add': |
||||
|
||||
$data = getUserToWork($userId, $workId, api_get_course_int_id()); |
||||
if (empty($data)) { |
||||
addUserToWork($userId, $workId, api_get_course_int_id()); |
||||
} |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?id='.$workId; |
||||
header('Location: '.$url); |
||||
exit; |
||||
|
||||
break; |
||||
case 'delete': |
||||
if (!empty($workId) && !empty($userId)) { |
||||
deleteUserToWork($userId, $workId, api_get_course_int_id()); |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?id='.$workId; |
||||
header('Location: '.$url); |
||||
exit; |
||||
} |
||||
break; |
||||
} |
||||
|
||||
Display :: display_header(null); |
||||
|
||||
echo Display::page_subheader(get_lang('UsersAdded')); |
||||
|
||||
$items = getAllUserToWork($workId, api_get_course_int_id()); |
||||
$usersAdded = array(); |
||||
if (!empty($items)) { |
||||
echo '<div class="well">'; |
||||
foreach ($items as $data) { |
||||
$myUserId = $data['user_id']; |
||||
$usersAdded[] = $myUserId; |
||||
$userInfo = api_get_user_info($myUserId); |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?action=delete&id='.$workId.'&user_id='.$myUserId; |
||||
$link = Display::url(get_lang('Delete'), $url); |
||||
echo $userInfo['complete_name'].' '.$link.'<br />'; |
||||
} |
||||
echo '</div>'; |
||||
} |
||||
|
||||
$userList = CourseManager::get_user_list_from_course_code($courseInfo['code'], api_get_session_id(), null, null, STUDENT); |
||||
|
||||
echo Display::page_subheader(get_lang('UserToAdd')); |
||||
if (!empty($userList)) { |
||||
echo '<div class="well">'; |
||||
foreach ($userList as $user) { |
||||
if (in_array($user['user_id'], $usersAdded)) { |
||||
continue; |
||||
} |
||||
$userName = api_get_person_name($user['firstname'], $user['lastname']); |
||||
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?action=add&id='.$workId.'&user_id='.$user['user_id']; |
||||
$link = Display::url(get_lang('Add'), $url); |
||||
echo $userName.' '.$link.'<br />'; |
||||
} |
||||
echo '</div>'; |
||||
} |
||||
|
||||
|
||||
echo '<hr /><div class="clear"></div>'; |
||||
@ -0,0 +1,11 @@ |
||||
language: php |
||||
|
||||
before_script: |
||||
- composer self-update |
||||
- composer install --dev --prefer-source |
||||
|
||||
php: |
||||
- 5.3.3 |
||||
- 5.3 |
||||
- 5.4 |
||||
- 5.5 |
||||
@ -0,0 +1,61 @@ |
||||
CHANGELOG |
||||
--------- |
||||
|
||||
* 1.5.0 (2013-06-21) |
||||
|
||||
* BC Break : ConfigurationInterface::get does not throw exceptions anymore |
||||
in case the key does not exist. Second argument is a default value to return |
||||
in case the key does not exist. |
||||
|
||||
* 1.4.1 (2013-05-23) |
||||
|
||||
* Add third parameter to BinaryInterface::command method to pass a listener or |
||||
an array of listener that will be registered just the time of the command. |
||||
|
||||
* 1.4.0 (2013-05-11) |
||||
|
||||
* Extract process run management to ProcessRunner. |
||||
* Add support for process listeners. |
||||
* Provides bundled DebugListener. |
||||
* Add BinaryInterface::command method. |
||||
* BC break : ProcessRunnerInterface::run now takes an SplObjectStorage containing |
||||
listeners as second argument. |
||||
* BC break : BinaryInterface no longer implements LoggerAwareInterface |
||||
as it is now supported by ProcessRunner. |
||||
|
||||
* 1.3.4 (2013-04-26) |
||||
|
||||
* Add BinaryDriver::run method. |
||||
|
||||
* 1.3.3 (2013-04-26) |
||||
|
||||
* Add BinaryDriver::createProcessMock method. |
||||
|
||||
* 1.3.2 (2013-04-26) |
||||
|
||||
* Add BinaryDriverTestCase for testing BinaryDriver implementations. |
||||
|
||||
* 1.3.1 (2013-04-24) |
||||
|
||||
* Add timeouts handling |
||||
|
||||
* 1.3.0 (2013-04-24) |
||||
|
||||
* Add BinaryInterface and AbstractBinary |
||||
|
||||
* 1.2.1 (2013-04-24) |
||||
|
||||
* Add ConfigurationAwareInterface |
||||
* Add ProcessBuilderAwareInterface |
||||
|
||||
* 1.2.0 (2013-04-24) |
||||
|
||||
* Add BinaryDriver\Configuration |
||||
|
||||
* 1.1.0 (2013-04-24) |
||||
|
||||
* Add support for timeouts via `setTimeout` method |
||||
|
||||
* 1.0.0 (2013-04-23) |
||||
|
||||
* First stable version. |
||||
@ -0,0 +1,21 @@ |
||||
BinaryDriver is released with MIT License : |
||||
|
||||
Copyright (c) 2013 Alchemy |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
||||
IN THE SOFTWARE. |
||||
@ -0,0 +1,190 @@ |
||||
# Binary Driver |
||||
|
||||
Binary-Driver is a set of PHP tools to build binary drivers. |
||||
|
||||
[](https://travis-ci.org/alchemy-fr/BinaryDriver) |
||||
|
||||
## Why ? |
||||
|
||||
You may wonder *Why building a library while I can use `exec` or |
||||
[symfony/process](https://github.com/symfony/Process) ?*. |
||||
|
||||
Here is a simple answer : |
||||
|
||||
- If you use `exec`, `passthru`, `system`, `proc_open` or any low level process |
||||
handling in PHP, you should have a look to [symfony/process](https://github.com/symfony/Process) |
||||
component that will provide an OO portable, testable and secure interface to |
||||
deal with this. It seems easy at first approach, but if you look at this |
||||
component [unit tests](https://github.com/symfony/Process/tree/master/Tests), |
||||
you will see that handling process in a simple interface can easily become a |
||||
nightmare. |
||||
|
||||
- If you already use symfony/process, and want to build binary drivers, you |
||||
will always have the same common set of methods and objects to configure, log, |
||||
debug, and generate processes. |
||||
This library is a base to implement any binary driver with this common set of |
||||
needs. |
||||
|
||||
## AbstractBinary |
||||
|
||||
`AbstractBinary` provides an abstract class to build a binary driver. It implements |
||||
`BinaryInterface`. |
||||
|
||||
Implementation example : |
||||
|
||||
```php |
||||
use Alchemy\BinaryDriver\AbstractBinary; |
||||
|
||||
class LsDriver extends AbstractBinary |
||||
{ |
||||
public function getName() |
||||
{ |
||||
return 'ls driver'; |
||||
} |
||||
} |
||||
|
||||
$parser = new LsParser(); |
||||
|
||||
$driver = Driver::load('ls'); |
||||
// will return the output of `ls -a -l` |
||||
$parser->parse($driver->command(array('-a', '-l'))); |
||||
``` |
||||
|
||||
### Binary detection troubleshooting |
||||
|
||||
If you are using Nginx with PHP-fpm, executable detection may not work because of an empty `$_ENV['path']`. |
||||
To avoid having an empty `PATH` environment variable, add the following line to your `fastcgi_params` |
||||
config file (replace `/your/current/path/` with the output of `printenv PATH`) : |
||||
|
||||
``` |
||||
fastcgi_param PATH /your/current/path |
||||
``` |
||||
|
||||
## Logging |
||||
|
||||
You can log events with a `Psr\Log\LoggerInterface` by passing it in the load |
||||
method as second argument : |
||||
|
||||
```php |
||||
$logger = new Monolog\Logger('driver'); |
||||
$driver = Driver::load('ls', $logger); |
||||
``` |
||||
|
||||
## Listeners |
||||
|
||||
You can add custom listeners on processes. |
||||
Listeners are built on top of [Evenement](https://github.com/igorw/evenement) |
||||
and must implement `Alchemy\BinaryDriver\ListenerInterface`. |
||||
|
||||
```php |
||||
use Symfony\Component\Process\Process; |
||||
|
||||
class DebugListener extends EventEmitter implements ListenerInterface |
||||
{ |
||||
public function handle($type, $data) |
||||
{ |
||||
foreach (explode(PHP_EOL, $data) as $line) { |
||||
$this->emit($type === Process::ERR ? 'error' : 'out', array($line)); |
||||
} |
||||
} |
||||
|
||||
public function forwardedEvents() |
||||
{ |
||||
// forward 'error' events to the BinaryInterface |
||||
return array('error'); |
||||
} |
||||
} |
||||
|
||||
$listener = new DebugListener(); |
||||
|
||||
$driver = CustomImplementation::load('php'); |
||||
|
||||
// adds listener |
||||
$driver->listen($listener); |
||||
|
||||
$driver->on('error', function ($line) { |
||||
echo '[ERROR] ' . $line . PHP_EOL; |
||||
}); |
||||
|
||||
// removes listener |
||||
$driver->unlisten($listener); |
||||
``` |
||||
|
||||
### Bundled listeners |
||||
|
||||
The debug listener is a simple listener to catch `stderr` and `stdout` outputs ; |
||||
read the implementation for customization. |
||||
|
||||
```php |
||||
use Alchemy\BinaryDriver\Listeners\DebugListener; |
||||
|
||||
$driver = CustomImplementation::load('php'); |
||||
$driver->listen(new DebugListener()); |
||||
|
||||
$driver->on('debug', function ($line) { |
||||
echo $line; |
||||
}); |
||||
``` |
||||
|
||||
## ProcessBuilderFactory |
||||
|
||||
ProcessBuilderFactory ease spawning processes by generating Symfony [Process] |
||||
(http://symfony.com/doc/master/components/process.html) objects. |
||||
|
||||
```php |
||||
use Alchemy\BinaryDriver\ProcessBuilderFactory; |
||||
|
||||
$factory = new ProcessBuilderFactory('/usr/bin/php'); |
||||
|
||||
// return a Symfony\Component\Process\Process |
||||
$process = $factory->create('-v'); |
||||
|
||||
// echoes '/usr/bin/php' '-v' |
||||
echo $process->getCommandLine(); |
||||
|
||||
$process = $factory->create(array('-r', 'echo "Hello !";')); |
||||
|
||||
// echoes '/usr/bin/php' '-r' 'echo "Hello !";' |
||||
echo $process->getCommandLine(); |
||||
``` |
||||
|
||||
## Configuration |
||||
|
||||
A simple configuration object, providing an `ArrayAccess` and `IteratorAggregate` |
||||
interface. |
||||
|
||||
```php |
||||
use Alchemy\BinaryDriver\Configuration; |
||||
|
||||
$conf = new Configuration(array('timeout' => 0)); |
||||
|
||||
echo $conf->get('timeout'); |
||||
|
||||
if ($conf->has('param')) { |
||||
$conf->remove('param'); |
||||
} |
||||
|
||||
$conf->set('timeout', 20); |
||||
|
||||
$conf->all(); |
||||
``` |
||||
|
||||
Same example using the `ArrayAccess` interface : |
||||
|
||||
```php |
||||
use Alchemy\BinaryDriver\Configuration; |
||||
|
||||
$conf = new Configuration(array('timeout' => 0)); |
||||
|
||||
echo $conf['timeout']; |
||||
|
||||
if (isset($conf['param'])) { |
||||
unset($conf['param']); |
||||
} |
||||
|
||||
$conf['timeout'] = 20; |
||||
``` |
||||
|
||||
## License |
||||
|
||||
This project is released under the MIT license. |
||||
@ -0,0 +1,38 @@ |
||||
{ |
||||
"name": "alchemy/binary-driver", |
||||
"type": "library", |
||||
"description": "A set of tools to build binary drivers", |
||||
"keywords": ["binary", "driver"], |
||||
"license": "MIT", |
||||
"authors": [ |
||||
{ |
||||
"name": "Nicolas Le Goff", |
||||
"email": "legoff.n@gmail.com" |
||||
}, |
||||
{ |
||||
"name": "Romain Neutron", |
||||
"email": "imprec@gmail.com", |
||||
"homepage": "http://www.lickmychip.com/" |
||||
}, |
||||
{ |
||||
"name": "Phraseanet Team", |
||||
"email": "info@alchemy.fr", |
||||
"homepage": "http://www.phraseanet.com/" |
||||
} |
||||
], |
||||
"require": { |
||||
"php" : ">=5.3.3", |
||||
"evenement/evenement" : "~1.0", |
||||
"monolog/monolog" : "~1.3", |
||||
"psr/log" : "~1.0", |
||||
"symfony/process" : "~2.0" |
||||
}, |
||||
"require-dev": { |
||||
"phpunit/phpunit" : "~3.7" |
||||
}, |
||||
"autoload": { |
||||
"psr-0": { |
||||
"Alchemy": "src" |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<phpunit backupGlobals="false" |
||||
backupStaticAttributes="false" |
||||
colors="true" |
||||
convertErrorsToExceptions="true" |
||||
convertNoticesToExceptions="true" |
||||
convertWarningsToExceptions="true" |
||||
processIsolation="false" |
||||
stopOnFailure="false" |
||||
syntaxCheck="true" |
||||
verbose="false" |
||||
bootstrap="tests/bootstrap.php" |
||||
> |
||||
<php> |
||||
<ini name="display_errors" value="on"/> |
||||
</php> |
||||
|
||||
<testsuites> |
||||
<testsuite> |
||||
<directory>tests</directory> |
||||
</testsuite> |
||||
</testsuites> |
||||
<filter> |
||||
<blacklist> |
||||
<directory>vendor</directory> |
||||
<directory>tests</directory> |
||||
</blacklist> |
||||
</filter> |
||||
|
||||
</phpunit> |
||||
|
||||
@ -0,0 +1,220 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
use Alchemy\BinaryDriver\Exception\ExecutableNotFoundException; |
||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException; |
||||
use Alchemy\BinaryDriver\Listeners\Listeners; |
||||
use Alchemy\BinaryDriver\Listeners\ListenerInterface; |
||||
use Evenement\EventEmitter; |
||||
use Monolog\Logger; |
||||
use Monolog\Handler\NullHandler; |
||||
use Psr\Log\LoggerInterface; |
||||
use Symfony\Component\Process\ExecutableFinder; |
||||
use Symfony\Component\Process\Process; |
||||
|
||||
abstract class AbstractBinary extends EventEmitter implements BinaryInterface |
||||
{ |
||||
/** @var ConfigurationInterface */ |
||||
protected $configuration; |
||||
|
||||
/** @var ProcessBuilderFactoryInterface */ |
||||
protected $factory; |
||||
|
||||
/** @var ProcessRunner */ |
||||
private $processRunner; |
||||
|
||||
/** @var Listeners */ |
||||
private $listenersManager; |
||||
|
||||
public function __construct(ProcessBuilderFactoryInterface $factory, LoggerInterface $logger, ConfigurationInterface $configuration) |
||||
{ |
||||
$this->factory = $factory; |
||||
$this->configuration = $configuration; |
||||
$this->processRunner = new ProcessRunner($logger, $this->getName()); |
||||
$this->listenersManager = new Listeners(); |
||||
$this->applyProcessConfiguration(); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function listen(ListenerInterface $listener) |
||||
{ |
||||
$this->listenersManager->register($listener, $this); |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function unlisten(ListenerInterface $listener) |
||||
{ |
||||
$this->listenersManager->unregister($listener, $this); |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function getConfiguration() |
||||
{ |
||||
return $this->configuration; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
* |
||||
* @return BinaryInterface |
||||
*/ |
||||
public function setConfiguration(ConfigurationInterface $configuration) |
||||
{ |
||||
$this->configuration = $configuration; |
||||
$this->applyProcessConfiguration(); |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function getProcessBuilderFactory() |
||||
{ |
||||
return $this->factory; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
* |
||||
* @return BinaryInterface |
||||
*/ |
||||
public function setProcessBuilderFactory(ProcessBuilderFactoryInterface $factory) |
||||
{ |
||||
$this->factory = $factory; |
||||
$this->applyProcessConfiguration(); |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function getProcessRunner() |
||||
{ |
||||
return $this->processRunner; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function setProcessRunner(ProcessRunnerInterface $runner) |
||||
{ |
||||
$this->processRunner = $runner; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function command($command, $bypassErrors = false, $listeners = null) |
||||
{ |
||||
if (!is_array($command)) { |
||||
$command = array($command); |
||||
} |
||||
|
||||
return $this->run($this->factory->create($command), $bypassErrors, $listeners); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public static function load($binaries, LoggerInterface $logger = null, $configuration = array()) |
||||
{ |
||||
$finder = new ExecutableFinder(); |
||||
$binary = null; |
||||
$binaries = is_array($binaries) ? $binaries : array($binaries); |
||||
|
||||
foreach ($binaries as $candidate) { |
||||
if (file_exists($candidate) && is_executable($candidate)) { |
||||
$binary = $candidate; |
||||
break; |
||||
} |
||||
if (null !== $binary = $finder->find($candidate)) { |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (null === $binary) { |
||||
throw new ExecutableNotFoundException(sprintf( |
||||
'Executable not found, proposed : %s', implode(', ', $binaries) |
||||
)); |
||||
} |
||||
|
||||
if (null === $logger) { |
||||
$logger = new Logger(__NAMESPACE__ . ' logger'); |
||||
$logger->pushHandler(new NullHandler()); |
||||
} |
||||
|
||||
$configuration = $configuration instanceof ConfigurationInterface ? $configuration : new Configuration($configuration); |
||||
|
||||
return new static(new ProcessBuilderFactory($binary), $logger, $configuration); |
||||
} |
||||
|
||||
/** |
||||
* Returns the name of the driver |
||||
* |
||||
* @return string |
||||
*/ |
||||
abstract public function getName(); |
||||
|
||||
/** |
||||
* Executes a process, logs events |
||||
* |
||||
* @param Process $process |
||||
* @param Boolean $bypassErrors Set to true to disable throwing ExecutionFailureExceptions |
||||
* @param ListenerInterface|array $listeners A listener or an array of listener to register for this unique run |
||||
* |
||||
* @return string The Process output |
||||
* |
||||
* @throws ExecutionFailureException in case of process failure. |
||||
*/ |
||||
protected function run(Process $process, $bypassErrors = false, $listeners = null) |
||||
{ |
||||
if (null !== $listeners) { |
||||
if (!is_array($listeners)) { |
||||
$listeners = array($listeners); |
||||
} |
||||
|
||||
$listenersManager = clone $this->listenersManager; |
||||
|
||||
foreach ($listeners as $listener) { |
||||
$listenersManager->register($listener, $this); |
||||
} |
||||
} else { |
||||
$listenersManager = $this->listenersManager; |
||||
} |
||||
|
||||
return $this->processRunner->run($process, $listenersManager->storage, $bypassErrors); |
||||
} |
||||
|
||||
private function applyProcessConfiguration() |
||||
{ |
||||
if ($this->configuration->has('timeout')) { |
||||
$this->factory->setTimeout($this->configuration->get('timeout')); |
||||
} |
||||
|
||||
return $this; |
||||
} |
||||
} |
||||
@ -0,0 +1,76 @@ |
||||
<?php |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
use Psr\Log\LoggerInterface; |
||||
use Symfony\Component\Process\Process; |
||||
|
||||
/** |
||||
* Convenient PHPUnit methods for testing BinaryDriverInterface implementations. |
||||
*/ |
||||
class BinaryDriverTestCase extends \PHPUnit_Framework_TestCase |
||||
{ |
||||
/** |
||||
* @return ProcessBuilderFactoryInterface |
||||
*/ |
||||
public function createProcessBuilderFactoryMock() |
||||
{ |
||||
return $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); |
||||
} |
||||
|
||||
/** |
||||
* @param integer $runs The number of runs expected |
||||
* @param Boolean $success True if the process expects to be successfull |
||||
* @param string $commandLine The commandline executed |
||||
* @param string $output The process output |
||||
* @param string $error The process error output |
||||
* |
||||
* @return Process |
||||
*/ |
||||
public function createProcessMock($runs = 1, $success = true, $commandLine = null, $output = null, $error = null, $callback = false) |
||||
{ |
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process') |
||||
->disableOriginalConstructor() |
||||
->getMock(); |
||||
|
||||
$builder = $process->expects($this->exactly($runs)) |
||||
->method('run'); |
||||
|
||||
if (true === $callback) { |
||||
$builder->with($this->isInstanceOf('Closure')); |
||||
} |
||||
|
||||
$process->expects($this->any()) |
||||
->method('isSuccessful') |
||||
->will($this->returnValue($success)); |
||||
|
||||
foreach (array( |
||||
'getOutput' => $output, |
||||
'getErrorOutput' => $error, |
||||
'getCommandLine' => $commandLine, |
||||
) as $command => $value) { |
||||
$process |
||||
->expects($this->any()) |
||||
->method($command) |
||||
->will($this->returnValue($value)); |
||||
} |
||||
|
||||
return $process; |
||||
} |
||||
|
||||
/** |
||||
* @return LoggerInterface |
||||
*/ |
||||
public function createLoggerMock() |
||||
{ |
||||
return $this->getMock('Psr\Log\LoggerInterface'); |
||||
} |
||||
|
||||
/** |
||||
* @return ConfigurationInterface |
||||
*/ |
||||
public function createConfigurationMock() |
||||
{ |
||||
return $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); |
||||
} |
||||
} |
||||
@ -0,0 +1,66 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
use Alchemy\BinaryDriver\Exception\ExecutableNotFoundException; |
||||
use Alchemy\BinaryDriver\Listeners\ListenerInterface; |
||||
use Psr\Log\LoggerInterface; |
||||
use Evenement\EventEmitterInterface; |
||||
|
||||
interface BinaryInterface extends ConfigurationAwareInterface, ProcessBuilderFactoryAwareInterface, ProcessRunnerAwareInterface, EventEmitterInterface |
||||
{ |
||||
/** |
||||
* Adds a listener to the binary driver |
||||
* |
||||
* @param ListenerInterface $listener |
||||
* |
||||
* @return BinaryInterface |
||||
*/ |
||||
public function listen(ListenerInterface $listener); |
||||
|
||||
/** |
||||
* Removes a listener from the binary driver |
||||
* |
||||
* @param ListenerInterface $listener |
||||
* |
||||
* @return BinaryInterface |
||||
*/ |
||||
public function unlisten(ListenerInterface $listener); |
||||
|
||||
/** |
||||
* Runs a command against the driver. |
||||
* |
||||
* Calling this method on a `ls` driver with the command `-a` would run `ls -a`. |
||||
* |
||||
* @param array|string $command A command or an array of command |
||||
* @param Boolean $bypassErrors If set to true, an erronous process will not throw an exception |
||||
* @param ListenerInterface|array $listeners A listener or an array of listeners to register for this unique run |
||||
* |
||||
* @return string The command output |
||||
* |
||||
* @throws ExecutionFailureException in case of process failure. |
||||
*/ |
||||
public function command($command, $bypassErrors = false, $listeners = null); |
||||
|
||||
/** |
||||
* Loads a binary |
||||
* |
||||
* @param string|array $binaries A binary name or an array of binary names |
||||
* @param null||LoggerInterface $logger A Logger |
||||
* @param array|ConfigurationInterface $configuration The configuration |
||||
* |
||||
* @throws ExecutableNotFoundException In case none of the binaries were found |
||||
* |
||||
* @return BinaryInterface |
||||
*/ |
||||
public static function load($binaries, LoggerInterface $logger = null, $configuration = array()); |
||||
} |
||||
@ -0,0 +1,107 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
class Configuration implements ConfigurationInterface |
||||
{ |
||||
private $data; |
||||
|
||||
public function __construct(array $data = array()) |
||||
{ |
||||
$this->data = $data; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function getIterator() |
||||
{ |
||||
return new \ArrayIterator($this->data); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function get($key, $default = null) |
||||
{ |
||||
return isset($this->data[$key]) ? $this->data[$key] : $default; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function set($key, $value) |
||||
{ |
||||
$this->data[$key] = $value; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function has($key) |
||||
{ |
||||
return array_key_exists($key, $this->data); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function remove($key) |
||||
{ |
||||
$value = $this->get($key); |
||||
unset($this->data[$key]); |
||||
|
||||
return $value; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function all() |
||||
{ |
||||
return $this->data; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function offsetExists($offset) |
||||
{ |
||||
return $this->has($offset); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function offsetGet($offset) |
||||
{ |
||||
return $this->get($offset); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function offsetSet($offset, $value) |
||||
{ |
||||
$this->set($offset, $value); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function offsetUnset($offset) |
||||
{ |
||||
$this->remove($offset); |
||||
} |
||||
} |
||||
@ -0,0 +1,29 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
interface ConfigurationAwareInterface |
||||
{ |
||||
/** |
||||
* Returns the configuration |
||||
* |
||||
* @return ConfigurationInterface |
||||
*/ |
||||
public function getConfiguration(); |
||||
|
||||
/** |
||||
* Set the configuration |
||||
* |
||||
* @param ConfigurationInterface $configuration |
||||
*/ |
||||
public function setConfiguration(ConfigurationInterface $configuration); |
||||
} |
||||
@ -0,0 +1,58 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
interface ConfigurationInterface extends \ArrayAccess, \IteratorAggregate |
||||
{ |
||||
/** |
||||
* Returns the value given a key from configuration |
||||
* |
||||
* @param string $key |
||||
* @param mixed $default The default value in case the key does not exist |
||||
* |
||||
* @return mixed |
||||
*/ |
||||
public function get($key, $default = null); |
||||
|
||||
/** |
||||
* Set a value to configuration |
||||
* |
||||
* @param string $key The key |
||||
* @param mixed $value The value corresponding to the key |
||||
*/ |
||||
public function set($key, $value); |
||||
|
||||
/** |
||||
* Tells if Configuration contains `$key` |
||||
* |
||||
* @param string $key |
||||
* |
||||
* @return Boolean |
||||
*/ |
||||
public function has($key); |
||||
|
||||
/** |
||||
* Removes a value given a key |
||||
* |
||||
* @param string $key |
||||
* |
||||
* @return mixed The previous value |
||||
*/ |
||||
public function remove($key); |
||||
|
||||
/** |
||||
* Returns all values set in the configuration |
||||
* |
||||
* @return array |
||||
*/ |
||||
public function all(); |
||||
} |
||||
@ -0,0 +1,16 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver\Exception; |
||||
|
||||
interface ExceptionInterface |
||||
{ |
||||
} |
||||
@ -0,0 +1,16 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver\Exception; |
||||
|
||||
class ExecutableNotFoundException extends \RuntimeException implements ExceptionInterface |
||||
{ |
||||
} |
||||
@ -0,0 +1,16 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver\Exception; |
||||
|
||||
class ExecutionFailureException extends \RuntimeException implements ExceptionInterface |
||||
{ |
||||
} |
||||
@ -0,0 +1,16 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver\Exception; |
||||
|
||||
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface |
||||
{ |
||||
} |
||||
@ -0,0 +1,58 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver\Listeners; |
||||
|
||||
use Evenement\EventEmitter; |
||||
use Symfony\Component\Process\Process; |
||||
|
||||
class DebugListener extends EventEmitter implements ListenerInterface |
||||
{ |
||||
private $prefixOut; |
||||
private $prefixErr; |
||||
private $eventOut; |
||||
private $eventErr; |
||||
|
||||
public function __construct($prefixOut = '[OUT] ', $prefixErr = '[ERROR] ', $eventOut = 'debug', $eventErr = 'debug') |
||||
{ |
||||
$this->prefixOut = $prefixOut; |
||||
$this->prefixErr = $prefixErr; |
||||
$this->eventOut = $eventOut; |
||||
$this->eventErr = $eventErr; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function handle($type, $data) |
||||
{ |
||||
if (Process::ERR === $type) { |
||||
$this->emitLines($this->eventErr, $this->prefixErr, $data); |
||||
} elseif (Process::OUT === $type) { |
||||
$this->emitLines($this->eventOut, $this->prefixOut, $data); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function forwardedEvents() |
||||
{ |
||||
return array_unique(array($this->eventErr, $this->eventOut)); |
||||
} |
||||
|
||||
private function emitLines($event, $prefix, $lines) |
||||
{ |
||||
foreach (explode("\n", $lines) as $line) { |
||||
$this->emit($event, array($prefix . $line)); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver\Listeners; |
||||
|
||||
use Evenement\EventEmitterInterface; |
||||
|
||||
interface ListenerInterface extends EventEmitterInterface |
||||
{ |
||||
/** |
||||
* Handle the output of a ProcessRunner |
||||
* |
||||
* @param string $type The data type, one of Process::ERR, Process::OUT constants |
||||
* @param string $data The output |
||||
*/ |
||||
public function handle($type, $data); |
||||
|
||||
/** |
||||
* An array of events that should be forwarded to BinaryInterface |
||||
* |
||||
* @return array |
||||
*/ |
||||
public function forwardedEvents(); |
||||
} |
||||
@ -0,0 +1,88 @@ |
||||
<?php |
||||
|
||||
namespace Alchemy\BinaryDriver\Listeners; |
||||
|
||||
use SplObjectStorage; |
||||
use Evenement\EventEmitter; |
||||
|
||||
class Listeners extends EventEmitter |
||||
{ |
||||
/** @var SplObjectStorage */ |
||||
public $storage; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->storage = new SplObjectStorage(); |
||||
} |
||||
|
||||
public function __clone() |
||||
{ |
||||
$storage = $this->storage; |
||||
$this->storage = new SplObjectStorage(); |
||||
$this->storage->addAll($storage); |
||||
} |
||||
|
||||
/** |
||||
* Registers a listener, pass the listener events to the target. |
||||
* |
||||
* @param ListenerInterface $listener |
||||
* @param null|EventEmitter $target |
||||
* |
||||
* @return ListenersInterface |
||||
*/ |
||||
public function register(ListenerInterface $listener, EventEmitter $target = null) |
||||
{ |
||||
$EElisteners = array(); |
||||
|
||||
if (null !== $target) { |
||||
$EElisteners = $this->forwardEvents($listener, $target, $listener->forwardedEvents()); |
||||
} |
||||
|
||||
$this->storage->attach($listener, $EElisteners); |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Unregisters a listener, removes the listener events from the target. |
||||
* |
||||
* @param ListenerInterface $listener |
||||
* |
||||
* @return ListenersInterface |
||||
* |
||||
* @throws InvalidArgumentException In case the listener is not registered |
||||
*/ |
||||
public function unregister(ListenerInterface $listener) |
||||
{ |
||||
if (!isset($this->storage[$listener])) { |
||||
throw new InvalidArgumentException('Listener is not registered.'); |
||||
} |
||||
|
||||
foreach ($this->storage[$listener] as $event => $EElistener) { |
||||
$listener->removeListener($event, $EElistener); |
||||
} |
||||
|
||||
$this->storage->detach($listener); |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
private function forwardEvents($source, $target, array $events) |
||||
{ |
||||
$EElisteners = array(); |
||||
|
||||
foreach ($events as $event) { |
||||
$listener = $this->createListener($event, $target); |
||||
$source->on($event, $EElisteners[$event] = $listener); |
||||
} |
||||
|
||||
return $EElisteners; |
||||
} |
||||
|
||||
private function createListener($event, $target) |
||||
{ |
||||
return function () use ($event, $target) { |
||||
$target->emit($event, func_get_args()); |
||||
}; |
||||
} |
||||
} |
||||
@ -0,0 +1,177 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
use Alchemy\BinaryDriver\Exception\InvalidArgumentException; |
||||
use Symfony\Component\Process\ProcessBuilder; |
||||
|
||||
class ProcessBuilderFactory implements ProcessBuilderFactoryInterface |
||||
{ |
||||
/** |
||||
* The binary path |
||||
* |
||||
* @var String |
||||
*/ |
||||
protected $binary; |
||||
|
||||
/** |
||||
* The timeout for the generated processes |
||||
* |
||||
* @var integer|float |
||||
*/ |
||||
private $timeout; |
||||
|
||||
/** |
||||
* An internal ProcessBuilder. |
||||
* |
||||
* Note that this one is used only if Symfony ProcessBuilder has method |
||||
* setPrefix (2.3) |
||||
* |
||||
* @var ProcessBuilder |
||||
*/ |
||||
private $builder; |
||||
|
||||
/** |
||||
* Tells whether Symfony LTS ProcessBuilder should be emulated or not. |
||||
* |
||||
* This symfony version provided a brand new ::setPrefix method. |
||||
* |
||||
* @var Boolean |
||||
*/ |
||||
public static $emulateSfLTS; |
||||
|
||||
/** |
||||
* Constructor |
||||
* |
||||
* @param String $binary The path to the binary |
||||
* |
||||
* @throws InvalidArgumentException In case binary path is invalid |
||||
*/ |
||||
public function __construct($binary) |
||||
{ |
||||
$this->detectEmulation(); |
||||
|
||||
if (!self::$emulateSfLTS) { |
||||
$this->builder = new ProcessBuilder(); |
||||
} |
||||
|
||||
$this->useBinary($binary); |
||||
} |
||||
|
||||
/** |
||||
* Covenient method for unit testing |
||||
* |
||||
* @return type |
||||
*/ |
||||
public function getBuilder() |
||||
{ |
||||
return $this->builder; |
||||
} |
||||
|
||||
/** |
||||
* Covenient method for unit testing |
||||
* |
||||
* @param ProcessBuilder $builder |
||||
* @return ProcessBuilderFactory |
||||
*/ |
||||
public function setBuilder(ProcessBuilder $builder) |
||||
{ |
||||
$this->builder = $builder; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* @inheritdoc |
||||
*/ |
||||
public function getBinary() |
||||
{ |
||||
return $this->binary; |
||||
} |
||||
|
||||
/** |
||||
* @inheritdoc |
||||
*/ |
||||
public function useBinary($binary) |
||||
{ |
||||
if (!is_executable($binary)) { |
||||
throw new InvalidArgumentException(sprintf('`%s` is not an executable binary', $binary)); |
||||
} |
||||
|
||||
$this->binary = $binary; |
||||
|
||||
if (!static::$emulateSfLTS) { |
||||
$this->builder->setPrefix($binary); |
||||
} |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* @inheritdoc |
||||
*/ |
||||
public function setTimeout($timeout) |
||||
{ |
||||
$this->timeout = $timeout; |
||||
|
||||
if (!static::$emulateSfLTS) { |
||||
$this->builder->setTimeout($this->timeout); |
||||
} |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* @inheritdoc |
||||
*/ |
||||
public function getTimeout() |
||||
{ |
||||
return $this->timeout; |
||||
} |
||||
|
||||
/** |
||||
* @inheritdoc |
||||
*/ |
||||
public function create($arguments = array()) |
||||
{ |
||||
if (null === $this->binary) { |
||||
throw new InvalidArgumentException('No binary set'); |
||||
} |
||||
|
||||
if (!is_array($arguments)) { |
||||
$arguments = array($arguments); |
||||
} |
||||
|
||||
if (static::$emulateSfLTS) { |
||||
array_unshift($arguments, $this->binary); |
||||
|
||||
return ProcessBuilder::create($arguments) |
||||
->setTimeout($this->timeout) |
||||
->getProcess(); |
||||
} else { |
||||
return $this->builder |
||||
->setArguments($arguments) |
||||
->getProcess(); |
||||
} |
||||
} |
||||
|
||||
private function detectEmulation() |
||||
{ |
||||
if (null !== static::$emulateSfLTS) { |
||||
return $this; |
||||
} |
||||
|
||||
static::$emulateSfLTS = !method_exists('Symfony\Component\Process\ProcessBuilder', 'setPrefix'); |
||||
|
||||
return $this; |
||||
} |
||||
} |
||||
@ -0,0 +1,29 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
interface ProcessBuilderFactoryAwareInterface |
||||
{ |
||||
/** |
||||
* Returns the current process builder factory |
||||
* |
||||
* @return ProcessBuilderFactoryInterface |
||||
*/ |
||||
public function getProcessBuilderFactory(); |
||||
|
||||
/** |
||||
* Set a process builder factory |
||||
* |
||||
* @param ProcessBuilderFactoryInterface $factory |
||||
*/ |
||||
public function setProcessBuilderFactory(ProcessBuilderFactoryInterface $factory); |
||||
} |
||||
@ -0,0 +1,65 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
use Alchemy\BinaryDriver\Exception\InvalidArgumentException; |
||||
use Symfony\Component\Process\Process; |
||||
|
||||
interface ProcessBuilderFactoryInterface |
||||
{ |
||||
/** |
||||
* Returns a new instance of Symfony Process |
||||
* |
||||
* @param string|array $arguments An argument or an array of arguments |
||||
* |
||||
* @return Process |
||||
* |
||||
* @throws InvalidArgumentException |
||||
*/ |
||||
public function create($arguments = array()); |
||||
|
||||
/** |
||||
* Returns the path to the binary that is used |
||||
* |
||||
* @return String |
||||
*/ |
||||
public function getBinary(); |
||||
|
||||
/** |
||||
* Sets the path to the binary |
||||
* |
||||
* @param String $binary A path to a binary |
||||
* |
||||
* @return ProcessBuilderFactoryInterface |
||||
* |
||||
* @throws InvalidArgumentException In case binary is not executable |
||||
*/ |
||||
public function useBinary($binary); |
||||
|
||||
/** |
||||
* Set the default timeout to apply on created processes. |
||||
* |
||||
* @param integer|float $timeout |
||||
* |
||||
* @return ProcessBuilderFactoryInterface |
||||
* |
||||
* @throws InvalidArgumentException In case the timeout is not valid |
||||
*/ |
||||
public function setTimeout($timeout); |
||||
|
||||
/** |
||||
* Returns the current timeout applied to the created processes. |
||||
* |
||||
* @return integer|float |
||||
*/ |
||||
public function getTimeout(); |
||||
} |
||||
@ -0,0 +1,104 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException; |
||||
use Psr\Log\LoggerInterface; |
||||
use SplObjectStorage; |
||||
use Symfony\Component\Process\Exception\RuntimeException; |
||||
use Symfony\Component\Process\Process; |
||||
|
||||
class ProcessRunner implements ProcessRunnerInterface |
||||
{ |
||||
/** @var LoggerInterface */ |
||||
private $logger; |
||||
|
||||
/** @var string */ |
||||
private $name; |
||||
|
||||
public function __construct(LoggerInterface $logger, $name) |
||||
{ |
||||
$this->logger = $logger; |
||||
$this->name = $name; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
* |
||||
* @return ProcessRunner |
||||
*/ |
||||
public function setLogger(LoggerInterface $logger) |
||||
{ |
||||
$this->logger = $logger; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* @return LoggerInterface |
||||
*/ |
||||
public function getLogger() |
||||
{ |
||||
return $this->logger; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function run(Process $process, SplObjectStorage $listeners, $bypassErrors) |
||||
{ |
||||
$this->logger->info(sprintf( |
||||
'%s running command %s', $this->name, $process->getCommandLine() |
||||
)); |
||||
|
||||
try { |
||||
$process->run($this->buildCallback($listeners)); |
||||
} catch (RuntimeException $e) { |
||||
if (!$bypassErrors) { |
||||
$this->doExecutionFailure($process->getCommandLine(), $e); |
||||
} |
||||
} |
||||
|
||||
if (!$bypassErrors && !$process->isSuccessful()) { |
||||
$this->doExecutionFailure($process->getCommandLine()); |
||||
} elseif (!$process->isSuccessful()) { |
||||
$this->logger->error(sprintf( |
||||
'%s failed to execute command %s', $this->name, $process->getCommandLine() |
||||
)); |
||||
|
||||
return; |
||||
} else { |
||||
$this->logger->info(sprintf('%s executed command successfully', $this->name)); |
||||
|
||||
return $process->getOutput(); |
||||
} |
||||
} |
||||
|
||||
private function buildCallback(SplObjectStorage $listeners) |
||||
{ |
||||
return function ($type, $data) use ($listeners) { |
||||
foreach ($listeners as $listener) { |
||||
$listener->handle($type, $data); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
private function doExecutionFailure($command, \Exception $e = null) |
||||
{ |
||||
$this->logger->error(sprintf( |
||||
'%s failed to execute command %s', $this->name, $command |
||||
)); |
||||
throw new ExecutionFailureException(sprintf( |
||||
'%s failed to execute command %s', $this->name, $command |
||||
), $e ? $e->getCode() : null, $e ?: null); |
||||
} |
||||
} |
||||
@ -0,0 +1,29 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
interface ProcessRunnerAwareInterface |
||||
{ |
||||
/** |
||||
* Returns the current process runner |
||||
* |
||||
* @return ProcessRunnerInterface |
||||
*/ |
||||
public function getProcessRunner(); |
||||
|
||||
/** |
||||
* Sets a process runner |
||||
* |
||||
* @param ProcessRunnerInterface $runner |
||||
*/ |
||||
public function setProcessRunner(ProcessRunnerInterface $runner); |
||||
} |
||||
@ -0,0 +1,33 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\BinaryDriver; |
||||
|
||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException; |
||||
use Psr\Log\LoggerAwareInterface; |
||||
use SplObjectStorage; |
||||
use Symfony\Component\Process\Process; |
||||
|
||||
interface ProcessRunnerInterface extends LoggerAwareInterface |
||||
{ |
||||
/** |
||||
* Executes a process, logs events |
||||
* |
||||
* @param Process $process |
||||
* @param SplObjectStorage $listeners Some listeners |
||||
* @param Boolean $bypassErrors Set to true to disable throwing ExecutionFailureExceptions |
||||
* |
||||
* @return string The Process output |
||||
* |
||||
* @throws ExecutionFailureException in case of process failure. |
||||
*/ |
||||
public function run(Process $process, SplObjectStorage $listeners, $bypassErrors); |
||||
} |
||||
@ -0,0 +1,297 @@ |
||||
<?php |
||||
|
||||
namespace Alchemy\Tests\BinaryDriver; |
||||
|
||||
use Alchemy\BinaryDriver\AbstractBinary; |
||||
use Alchemy\BinaryDriver\BinaryDriverTestCase; |
||||
use Alchemy\BinaryDriver\Configuration; |
||||
use Symfony\Component\Process\ExecutableFinder; |
||||
|
||||
class AbstractBinaryTest extends BinaryDriverTestCase |
||||
{ |
||||
protected function getPhpBinary() |
||||
{ |
||||
$finder = new ExecutableFinder(); |
||||
$php = $finder->find('php'); |
||||
|
||||
if (null === $php) { |
||||
$this->markTestSkipped('Unable to find a php binary'); |
||||
} |
||||
|
||||
return $php; |
||||
} |
||||
|
||||
public function testSimpleLoadWithBinaryPath() |
||||
{ |
||||
$php = $this->getPhpBinary(); |
||||
$imp = Implementation::load($php); |
||||
$this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp); |
||||
|
||||
$this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary()); |
||||
} |
||||
|
||||
public function testMultipleLoadWithBinaryPath() |
||||
{ |
||||
$php = $this->getPhpBinary(); |
||||
$imp = Implementation::load(array('/zz/path/to/unexisting/command', $php)); |
||||
$this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp); |
||||
|
||||
$this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary()); |
||||
} |
||||
|
||||
public function testSimpleLoadWithBinaryName() |
||||
{ |
||||
$php = $this->getPhpBinary(); |
||||
$imp = Implementation::load('php'); |
||||
$this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp); |
||||
|
||||
$this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary()); |
||||
} |
||||
|
||||
public function testMultipleLoadWithBinaryName() |
||||
{ |
||||
$php = $this->getPhpBinary(); |
||||
$imp = Implementation::load(array('bachibouzouk', 'php')); |
||||
$this->assertInstanceOf('Alchemy\Tests\BinaryDriver\Implementation', $imp); |
||||
|
||||
$this->assertEquals($php, $imp->getProcessBuilderFactory()->getBinary()); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException Alchemy\BinaryDriver\Exception\ExecutableNotFoundException |
||||
*/ |
||||
public function testLoadWithMultiplePathExpectingAFailure() |
||||
{ |
||||
Implementation::load(array('bachibouzouk', 'moribon')); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException Alchemy\BinaryDriver\Exception\ExecutableNotFoundException |
||||
*/ |
||||
public function testLoadWithUniquePathExpectingAFailure() |
||||
{ |
||||
Implementation::load('bachibouzouk'); |
||||
} |
||||
|
||||
public function testLoadWithCustomLogger() |
||||
{ |
||||
$logger = $this->getMock('Psr\Log\LoggerInterface'); |
||||
$imp = Implementation::load('php', $logger); |
||||
|
||||
$this->assertEquals($logger, $imp->getProcessRunner()->getLogger()); |
||||
} |
||||
|
||||
public function testLoadWithCustomConfigurationAsArray() |
||||
{ |
||||
$conf = array('timeout' => 200); |
||||
$imp = Implementation::load('php', null, $conf); |
||||
|
||||
$this->assertEquals($conf, $imp->getConfiguration()->all()); |
||||
} |
||||
|
||||
public function testLoadWithCustomConfigurationAsObject() |
||||
{ |
||||
$conf = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); |
||||
$imp = Implementation::load('php', null, $conf); |
||||
|
||||
$this->assertEquals($conf, $imp->getConfiguration()); |
||||
} |
||||
|
||||
public function testProcessBuilderFactoryGetterAndSetters() |
||||
{ |
||||
$imp = Implementation::load('php'); |
||||
$factory = $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); |
||||
|
||||
$imp->setProcessBuilderFactory($factory); |
||||
$this->assertEquals($factory, $imp->getProcessBuilderFactory()); |
||||
} |
||||
|
||||
public function testConfigurationGetterAndSetters() |
||||
{ |
||||
$imp = Implementation::load('php'); |
||||
$conf = $this->getMock('Alchemy\BinaryDriver\ConfigurationInterface'); |
||||
|
||||
$imp->setConfiguration($conf); |
||||
$this->assertEquals($conf, $imp->getConfiguration()); |
||||
} |
||||
|
||||
public function testTimeoutIsSetOnConstruction() |
||||
{ |
||||
$imp = Implementation::load('php', null, array('timeout' => 42)); |
||||
$this->assertEquals(42, $imp->getProcessBuilderFactory()->getTimeout()); |
||||
} |
||||
|
||||
public function testTimeoutIsSetOnConfigurationSetting() |
||||
{ |
||||
$imp = Implementation::load('php', null); |
||||
$imp->setConfiguration(new Configuration(array('timeout' => 42))); |
||||
$this->assertEquals(42, $imp->getProcessBuilderFactory()->getTimeout()); |
||||
} |
||||
|
||||
public function testTimeoutIsSetOnProcessBuilderSetting() |
||||
{ |
||||
$imp = Implementation::load('php', null, array('timeout' => 42)); |
||||
|
||||
$factory = $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); |
||||
$factory->expects($this->once()) |
||||
->method('setTimeout') |
||||
->with(42); |
||||
|
||||
$imp->setProcessBuilderFactory($factory); |
||||
} |
||||
|
||||
public function testListenRegistersAListener() |
||||
{ |
||||
$imp = Implementation::load('php'); |
||||
|
||||
$listeners = $this->getMockBuilder('Alchemy\BinaryDriver\Listeners\Listeners') |
||||
->disableOriginalConstructor() |
||||
->getMock(); |
||||
|
||||
$listener = $this->getMock('Alchemy\BinaryDriver\Listeners\ListenerInterface'); |
||||
|
||||
$listeners->expects($this->once()) |
||||
->method('register') |
||||
->with($this->equalTo($listener), $this->equalTo($imp)); |
||||
|
||||
$reflexion = new \ReflectionClass('Alchemy\BinaryDriver\AbstractBinary'); |
||||
$prop = $reflexion->getProperty('listenersManager'); |
||||
$prop->setAccessible(true); |
||||
$prop->setValue($imp, $listeners); |
||||
|
||||
$imp->listen($listener); |
||||
} |
||||
|
||||
/** |
||||
* @dataProvider provideCommandParameters |
||||
*/ |
||||
public function testCommandRunsAProcess($parameters, $bypassErrors, $expectedParameters, $output) |
||||
{ |
||||
$imp = Implementation::load('php'); |
||||
$factory = $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); |
||||
$processRunner = $this->getMock('Alchemy\BinaryDriver\ProcessRunnerInterface'); |
||||
|
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process') |
||||
->disableOriginalConstructor() |
||||
->getMock(); |
||||
|
||||
$processRunner->expects($this->once()) |
||||
->method('run') |
||||
->with($this->equalTo($process), $this->isInstanceOf('SplObjectStorage'), $this->equalTo($bypassErrors)) |
||||
->will($this->returnValue($output)); |
||||
|
||||
$factory->expects($this->once()) |
||||
->method('create') |
||||
->with($expectedParameters) |
||||
->will($this->returnValue($process)); |
||||
|
||||
$imp->setProcessBuilderFactory($factory); |
||||
$imp->setProcessRunner($processRunner); |
||||
|
||||
$this->assertEquals($output, $imp->command($parameters, $bypassErrors)); |
||||
} |
||||
|
||||
/** |
||||
* @dataProvider provideCommandWithListenersParameters |
||||
*/ |
||||
public function testCommandWithTemporaryListeners($parameters, $bypassErrors, $expectedParameters, $output, $count, $listeners) |
||||
{ |
||||
$imp = Implementation::load('php'); |
||||
$factory = $this->getMock('Alchemy\BinaryDriver\ProcessBuilderFactoryInterface'); |
||||
$processRunner = $this->getMock('Alchemy\BinaryDriver\ProcessRunnerInterface'); |
||||
|
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process') |
||||
->disableOriginalConstructor() |
||||
->getMock(); |
||||
|
||||
$firstStorage = $secondStorage = null; |
||||
|
||||
$processRunner->expects($this->exactly(2)) |
||||
->method('run') |
||||
->with($this->equalTo($process), $this->isInstanceOf('SplObjectStorage'), $this->equalTo($bypassErrors)) |
||||
->will($this->returnCallback(function ($process, $storage, $errors) use ($output, &$firstStorage, &$secondStorage) { |
||||
if (null === $firstStorage) { |
||||
$firstStorage = $storage; |
||||
} else { |
||||
$secondStorage = $storage; |
||||
} |
||||
|
||||
return $output; |
||||
})); |
||||
|
||||
$factory->expects($this->exactly(2)) |
||||
->method('create') |
||||
->with($expectedParameters) |
||||
->will($this->returnValue($process)); |
||||
|
||||
$imp->setProcessBuilderFactory($factory); |
||||
$imp->setProcessRunner($processRunner); |
||||
|
||||
$this->assertEquals($output, $imp->command($parameters, $bypassErrors, $listeners)); |
||||
$this->assertCount($count, $firstStorage); |
||||
$this->assertEquals($output, $imp->command($parameters, $bypassErrors)); |
||||
$this->assertCount(0, $secondStorage); |
||||
} |
||||
|
||||
public function provideCommandWithListenersParameters() |
||||
{ |
||||
$listener = $this->getMock('Alchemy\BinaryDriver\Listeners\ListenerInterface'); |
||||
$listener->expects($this->any()) |
||||
->method('forwardedEvents') |
||||
->will($this->returnValue(array())); |
||||
|
||||
$listener2 = $this->getMock('Alchemy\BinaryDriver\Listeners\ListenerInterface'); |
||||
$listener2->expects($this->any()) |
||||
->method('forwardedEvents') |
||||
->will($this->returnValue(array())); |
||||
|
||||
return array( |
||||
array('-a', false, array('-a'), 'loubda', 2, array($listener, $listener2)), |
||||
array('-a', false, array('-a'), 'loubda', 1, array($listener)), |
||||
array('-a', false, array('-a'), 'loubda', 1, $listener), |
||||
array('-a', false, array('-a'), 'loubda', 0, array()), |
||||
); |
||||
} |
||||
|
||||
public function provideCommandParameters() |
||||
{ |
||||
return array( |
||||
array('-a', false, array('-a'), 'loubda'), |
||||
array('-a', true, array('-a'), 'loubda'), |
||||
array('-a -b', false, array('-a -b'), 'loubda'), |
||||
array(array('-a'), false, array('-a'), 'loubda'), |
||||
array(array('-a'), true, array('-a'), 'loubda'), |
||||
array(array('-a', '-b'), false, array('-a', '-b'), 'loubda'), |
||||
); |
||||
} |
||||
|
||||
public function testUnlistenUnregistersAListener() |
||||
{ |
||||
$imp = Implementation::load('php'); |
||||
|
||||
$listeners = $this->getMockBuilder('Alchemy\BinaryDriver\Listeners\Listeners') |
||||
->disableOriginalConstructor() |
||||
->getMock(); |
||||
|
||||
$listener = $this->getMock('Alchemy\BinaryDriver\Listeners\ListenerInterface'); |
||||
|
||||
$listeners->expects($this->once()) |
||||
->method('unregister') |
||||
->with($this->equalTo($listener), $this->equalTo($imp)); |
||||
|
||||
$reflexion = new \ReflectionClass('Alchemy\BinaryDriver\AbstractBinary'); |
||||
$prop = $reflexion->getProperty('listenersManager'); |
||||
$prop->setAccessible(true); |
||||
$prop->setValue($imp, $listeners); |
||||
|
||||
$imp->unlisten($listener); |
||||
} |
||||
} |
||||
|
||||
class Implementation extends AbstractBinary |
||||
{ |
||||
public function getName() |
||||
{ |
||||
return 'Implementation'; |
||||
} |
||||
} |
||||
@ -0,0 +1,97 @@ |
||||
<?php |
||||
|
||||
namespace Alchemy\Tests\BinaryDriver; |
||||
|
||||
use Symfony\Component\Process\ExecutableFinder; |
||||
use Alchemy\BinaryDriver\ProcessBuilderFactory; |
||||
|
||||
abstract class AbstractProcessBuilderFactoryTest extends \PHPUnit_Framework_TestCase |
||||
{ |
||||
public static $phpBinary; |
||||
|
||||
private $original; |
||||
/** |
||||
* @return ProcessBuilderFactory |
||||
*/ |
||||
abstract protected function getProcessBuilderFactory($binary); |
||||
|
||||
public function setUp() |
||||
{ |
||||
ProcessBuilderFactory::$emulateSfLTS = null; |
||||
if (null === static::$phpBinary) { |
||||
$this->markTestSkipped('Unable to detect php binary, skipping'); |
||||
} |
||||
} |
||||
|
||||
public static function setUpBeforeClass() |
||||
{ |
||||
$finder = new ExecutableFinder(); |
||||
static::$phpBinary = $finder->find('php'); |
||||
} |
||||
|
||||
public function testThatBinaryIsSetOnConstruction() |
||||
{ |
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary); |
||||
$this->assertEquals(static::$phpBinary, $factory->getBinary()); |
||||
} |
||||
|
||||
public function testGetSetBinary() |
||||
{ |
||||
$finder = new ExecutableFinder(); |
||||
$phpUnit = $finder->find('phpunit'); |
||||
|
||||
if (null === $phpUnit) { |
||||
$this->markTestSkipped('Unable to detect phpunit binary, skipping'); |
||||
} |
||||
|
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary); |
||||
$factory->useBinary($phpUnit); |
||||
$this->assertEquals($phpUnit, $factory->getBinary()); |
||||
} |
||||
|
||||
/** |
||||
* @expectedException Alchemy\BinaryDriver\Exception\InvalidArgumentException |
||||
*/ |
||||
public function testUseNonExistantBinary() |
||||
{ |
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary); |
||||
$factory->useBinary('itissureitdoesnotexist'); |
||||
} |
||||
|
||||
public function testCreateShouldReturnAProcess() |
||||
{ |
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary); |
||||
$process = $factory->create(); |
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Process\Process', $process); |
||||
$this->assertEquals("'".static::$phpBinary."'", $process->getCommandLine()); |
||||
} |
||||
|
||||
public function testCreateWithStringArgument() |
||||
{ |
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary); |
||||
$process = $factory->create('-v'); |
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Process\Process', $process); |
||||
$this->assertEquals("'".static::$phpBinary."' '-v'", $process->getCommandLine()); |
||||
} |
||||
|
||||
public function testCreateWithArrayArgument() |
||||
{ |
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary); |
||||
$process = $factory->create(array('-r', 'echo "Hello !";')); |
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Process\Process', $process); |
||||
$this->assertEquals("'".static::$phpBinary."' '-r' 'echo \"Hello !\";'", $process->getCommandLine()); |
||||
} |
||||
|
||||
public function testCreateWithTimeout() |
||||
{ |
||||
$factory = $this->getProcessBuilderFactory(static::$phpBinary); |
||||
$factory->setTimeout(200); |
||||
$process = $factory->create(array('-i')); |
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Process\Process', $process); |
||||
$this->assertEquals(200, $process->getTimeout()); |
||||
} |
||||
} |
||||
@ -0,0 +1,78 @@ |
||||
<?php |
||||
|
||||
namespace Alchemy\Tests\BinaryDriver; |
||||
|
||||
use Alchemy\BinaryDriver\Configuration; |
||||
|
||||
class ConfigurationTest extends \PHPUnit_Framework_TestCase |
||||
{ |
||||
public function testArrayAccessImplementation() |
||||
{ |
||||
$configuration = new Configuration(array('key' => 'value')); |
||||
|
||||
$this->assertTrue(isset($configuration['key'])); |
||||
$this->assertEquals('value', $configuration['key']); |
||||
|
||||
$this->assertFalse(isset($configuration['key2'])); |
||||
unset($configuration['key']); |
||||
$this->assertFalse(isset($configuration['key'])); |
||||
|
||||
$configuration['key2'] = 'value2'; |
||||
$this->assertTrue(isset($configuration['key2'])); |
||||
$this->assertEquals('value2', $configuration['key2']); |
||||
} |
||||
|
||||
public function testGetOnNonExistentKeyShouldReturnDefaultValue() |
||||
{ |
||||
$conf = new Configuration(); |
||||
$this->assertEquals('booba', $conf->get('hooba', 'booba')); |
||||
$this->assertEquals(null, $conf->get('hooba')); |
||||
} |
||||
|
||||
public function testSetHasGetRemove() |
||||
{ |
||||
$configuration = new Configuration(array('key' => 'value')); |
||||
|
||||
$this->assertTrue($configuration->has('key')); |
||||
$this->assertEquals('value', $configuration->get('key')); |
||||
|
||||
$this->assertFalse($configuration->has('key2')); |
||||
$configuration->remove('key'); |
||||
$this->assertFalse($configuration->has('key')); |
||||
|
||||
$configuration->set('key2', 'value2'); |
||||
$this->assertTrue($configuration->has('key2')); |
||||
$this->assertEquals('value2', $configuration->get('key2')); |
||||
} |
||||
|
||||
public function testIterator() |
||||
{ |
||||
$data = array( |
||||
'key1' => 'value1', |
||||
'key2' => 'value2', |
||||
'key3' => 'value3', |
||||
); |
||||
|
||||
$captured = array(); |
||||
$conf = new Configuration($data); |
||||
|
||||
foreach ($conf as $key => $value) { |
||||
$captured[$key] = $value; |
||||
} |
||||
|
||||
$this->assertEquals($data, $captured); |
||||
} |
||||
|
||||
public function testAll() |
||||
{ |
||||
$data = array( |
||||
'key1' => 'value1', |
||||
'key2' => 'value2', |
||||
'key3' => 'value3', |
||||
); |
||||
|
||||
$conf = new Configuration($data); |
||||
$this->assertEquals($data, $conf->all()); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,66 @@ |
||||
<?php |
||||
|
||||
namespace Alchemy\Tests\BinaryDriver; |
||||
|
||||
use Symfony\Component\Process\ProcessBuilder; |
||||
use Alchemy\BinaryDriver\ProcessBuilderFactory; |
||||
use Symfony\Component\Process\Process; |
||||
|
||||
class LTSProcessBuilderFactoryTest extends AbstractProcessBuilderFactoryTest |
||||
{ |
||||
protected function getProcessBuilderFactory($binary) |
||||
{ |
||||
$factory = new ProcessBuilderFactory($binary); |
||||
$factory->setBuilder(new LTSProcessBuilder()); |
||||
ProcessBuilderFactory::$emulateSfLTS = false; |
||||
$factory->useBinary($binary); |
||||
|
||||
return $factory; |
||||
} |
||||
} |
||||
|
||||
class LTSProcessBuilder extends ProcessBuilder |
||||
{ |
||||
private $arguments; |
||||
private $prefix; |
||||
private $timeout; |
||||
|
||||
public function __construct(array $arguments = array()) |
||||
{ |
||||
$this->arguments = $arguments; |
||||
parent::__construct($arguments); |
||||
} |
||||
|
||||
public function setArguments(array $arguments) |
||||
{ |
||||
$this->arguments = $arguments; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function setPrefix($prefix) |
||||
{ |
||||
$this->prefix = $prefix; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function setTimeout($timeout) |
||||
{ |
||||
$this->timeout = $timeout; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
public function getProcess() |
||||
{ |
||||
if (!$this->prefix && !count($this->arguments)) { |
||||
throw new LogicException('You must add() command arguments before calling getProcess().'); |
||||
} |
||||
|
||||
$args = $this->prefix ? array_merge(array($this->prefix), $this->arguments) : $this->arguments; |
||||
$script = implode(' ', array_map('escapeshellarg', $args)); |
||||
|
||||
return new Process($script, null, null, null, $this->timeout); |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@ |
||||
<?php |
||||
|
||||
namespace Alchemy\Tests\BinaryDriver\Listeners; |
||||
|
||||
use Alchemy\BinaryDriver\Listeners\DebugListener; |
||||
use Symfony\Component\Process\Process; |
||||
|
||||
class DebugListenerTest extends \PHPUnit_Framework_TestCase |
||||
{ |
||||
public function testHandle() |
||||
{ |
||||
$listener = new DebugListener(); |
||||
|
||||
$lines = array(); |
||||
$listener->on('debug', function ($line) use (&$lines) { |
||||
$lines[] = $line; |
||||
}); |
||||
$listener->handle(Process::ERR, "first line\nsecond line"); |
||||
$listener->handle(Process::OUT, "cool output"); |
||||
$listener->handle('unknown', "lalala"); |
||||
$listener->handle(Process::OUT, "another output\n"); |
||||
|
||||
$expected = array( |
||||
'[ERROR] first line', |
||||
'[ERROR] second line', |
||||
'[OUT] cool output', |
||||
'[OUT] another output', |
||||
'[OUT] ', |
||||
); |
||||
|
||||
$this->assertEquals($expected, $lines); |
||||
} |
||||
} |
||||
@ -0,0 +1,92 @@ |
||||
<?php |
||||
|
||||
namespace Alchemy\Tests\BinaryDriver\Listeners; |
||||
|
||||
use Alchemy\BinaryDriver\Listeners\Listeners; |
||||
use Evenement\EventEmitter; |
||||
use Alchemy\BinaryDriver\Listeners\ListenerInterface; |
||||
|
||||
class ListenersTest extends \PHPUnit_Framework_TestCase |
||||
{ |
||||
public function testRegister() |
||||
{ |
||||
$listener = new TestListener(); |
||||
|
||||
$listeners = new Listeners(); |
||||
$listeners->register($listener); |
||||
|
||||
$n = 0; |
||||
$listener->on('received', function ($type, $data) use (&$n, &$capturedType, &$capturedData) { |
||||
$n++; |
||||
$capturedData = $data; |
||||
$capturedType = $type; |
||||
}); |
||||
|
||||
$type = 'type'; |
||||
$data = 'data'; |
||||
|
||||
$listener->handle($type, $data); |
||||
$listener->handle($type, $data); |
||||
|
||||
$listeners->unregister($listener); |
||||
|
||||
$listener->handle($type, $data); |
||||
|
||||
$this->assertEquals(3, $n); |
||||
$this->assertEquals($type, $capturedType); |
||||
$this->assertEquals($data, $capturedData); |
||||
} |
||||
|
||||
public function testRegisterAndForwardThenUnregister() |
||||
{ |
||||
$listener = new TestListener(); |
||||
$target = new EventEmitter(); |
||||
|
||||
$n = 0; |
||||
$target->on('received', function ($type, $data) use (&$n, &$capturedType, &$capturedData) { |
||||
$n++; |
||||
$capturedData = $data; |
||||
$capturedType = $type; |
||||
}); |
||||
|
||||
$m = 0; |
||||
$listener->on('received', function ($type, $data) use (&$m, &$capturedType2, &$capturedData2) { |
||||
$m++; |
||||
$capturedData2 = $data; |
||||
$capturedType2 = $type; |
||||
}); |
||||
|
||||
$listeners = new Listeners(); |
||||
$listeners->register($listener, $target); |
||||
|
||||
$type = 'type'; |
||||
$data = 'data'; |
||||
|
||||
$listener->handle($type, $data); |
||||
$listener->handle($type, $data); |
||||
|
||||
$listeners->unregister($listener, $target); |
||||
|
||||
$listener->handle($type, $data); |
||||
|
||||
$this->assertEquals(2, $n); |
||||
$this->assertEquals(3, $m); |
||||
$this->assertEquals($type, $capturedType); |
||||
$this->assertEquals($data, $capturedData); |
||||
$this->assertEquals($type, $capturedType2); |
||||
$this->assertEquals($data, $capturedData2); |
||||
} |
||||
} |
||||
|
||||
class TestListener extends EventEmitter implements ListenerInterface |
||||
{ |
||||
public function handle($type, $data) |
||||
{ |
||||
$this->emit('received', array($type, $data)); |
||||
} |
||||
|
||||
public function forwardedEvents() |
||||
{ |
||||
return array('received'); |
||||
} |
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
<?php |
||||
|
||||
namespace Alchemy\Tests\BinaryDriver; |
||||
|
||||
use Alchemy\BinaryDriver\ProcessBuilderFactory; |
||||
|
||||
class NONLTSProcessBuilderFactoryTest extends AbstractProcessBuilderFactoryTest |
||||
{ |
||||
protected function getProcessBuilderFactory($binary) |
||||
{ |
||||
ProcessBuilderFactory::$emulateSfLTS = true; |
||||
|
||||
return new ProcessBuilderFactory($binary); |
||||
} |
||||
} |
||||
@ -0,0 +1,208 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Alchemy\BinaryDriver. |
||||
* |
||||
* (c) Alchemy <info@alchemy.fr> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Alchemy\Tests\BinaryDriver; |
||||
|
||||
use Alchemy\BinaryDriver\ProcessRunner; |
||||
use Alchemy\BinaryDriver\BinaryDriverTestCase; |
||||
use Alchemy\BinaryDriver\Exception\ExecutionFailureException; |
||||
use Alchemy\BinaryDriver\Listeners\ListenerInterface; |
||||
use Evenement\EventEmitter; |
||||
use Symfony\Component\Process\Exception\RuntimeException as ProcessRuntimeException; |
||||
|
||||
class ProcessRunnerTest extends BinaryDriverTestCase |
||||
{ |
||||
public function getProcessRunner($logger) |
||||
{ |
||||
return new ProcessRunner($logger, 'test-runner'); |
||||
} |
||||
|
||||
public function testRunSuccessFullProcess() |
||||
{ |
||||
$logger = $this->createLoggerMock(); |
||||
$runner = $this->getProcessRunner($logger); |
||||
|
||||
$process = $this->createProcessMock(1, true, '--helloworld--', "Kikoo Romain", null, true); |
||||
|
||||
$logger |
||||
->expects($this->never()) |
||||
->method('error'); |
||||
$logger |
||||
->expects($this->exactly(2)) |
||||
->method('info'); |
||||
|
||||
$this->assertEquals('Kikoo Romain', $runner->run($process, new \SplObjectStorage(), false)); |
||||
} |
||||
|
||||
public function testRunSuccessFullProcessBypassingErrors() |
||||
{ |
||||
$logger = $this->createLoggerMock(); |
||||
$runner = $this->getProcessRunner($logger); |
||||
|
||||
$process = $this->createProcessMock(1, true, '--helloworld--', "Kikoo Romain", null, true); |
||||
|
||||
$logger |
||||
->expects($this->never()) |
||||
->method('error'); |
||||
$logger |
||||
->expects($this->exactly(2)) |
||||
->method('info'); |
||||
|
||||
$this->assertEquals('Kikoo Romain', $runner->run($process, new \SplObjectStorage(), true)); |
||||
} |
||||
|
||||
public function testRunFailingProcess() |
||||
{ |
||||
$logger = $this->createLoggerMock(); |
||||
$runner = $this->getProcessRunner($logger); |
||||
|
||||
$process = $this->createProcessMock(1, false, '--helloworld--', null, null, true); |
||||
|
||||
$logger |
||||
->expects($this->once()) |
||||
->method('error'); |
||||
$logger |
||||
->expects($this->once()) |
||||
->method('info'); |
||||
|
||||
try { |
||||
$runner->run($process, new \SplObjectStorage(), false); |
||||
$this->fail('An exception should have been raised'); |
||||
} catch (ExecutionFailureException $e) { |
||||
|
||||
} |
||||
} |
||||
|
||||
public function testRunFailingProcessWithException() |
||||
{ |
||||
$logger = $this->createLoggerMock(); |
||||
$runner = $this->getProcessRunner($logger); |
||||
|
||||
$exception = new ProcessRuntimeException('Process Failed'); |
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process') |
||||
->disableOriginalConstructor() |
||||
->getMock(); |
||||
$process->expects($this->once()) |
||||
->method('run') |
||||
->will($this->throwException($exception)); |
||||
|
||||
$logger |
||||
->expects($this->once()) |
||||
->method('error'); |
||||
$logger |
||||
->expects($this->once()) |
||||
->method('info'); |
||||
|
||||
try { |
||||
$runner->run($process, new \SplObjectStorage(), false); |
||||
$this->fail('An exception should have been raised'); |
||||
} catch (ExecutionFailureException $e) { |
||||
$this->assertEquals($exception, $e->getPrevious()); |
||||
} |
||||
} |
||||
|
||||
public function testRunfailingProcessBypassingErrors() |
||||
{ |
||||
$logger = $this->createLoggerMock(); |
||||
$runner = $this->getProcessRunner($logger); |
||||
|
||||
$process = $this->createProcessMock(1, false, '--helloworld--', 'Hello output', null, true); |
||||
|
||||
$logger |
||||
->expects($this->once()) |
||||
->method('error'); |
||||
$logger |
||||
->expects($this->once()) |
||||
->method('info'); |
||||
|
||||
$this->assertNull($runner->run($process, new \SplObjectStorage(), true)); |
||||
} |
||||
|
||||
public function testRunFailingProcessWithExceptionBypassingErrors() |
||||
{ |
||||
$logger = $this->createLoggerMock(); |
||||
$runner = $this->getProcessRunner($logger); |
||||
|
||||
$exception = new ProcessRuntimeException('Process Failed'); |
||||
$process = $this->getMockBuilder('Symfony\Component\Process\Process') |
||||
->disableOriginalConstructor() |
||||
->getMock(); |
||||
$process->expects($this->once()) |
||||
->method('run') |
||||
->will($this->throwException($exception)); |
||||
|
||||
$logger |
||||
->expects($this->once()) |
||||
->method('error'); |
||||
$logger |
||||
->expects($this->once()) |
||||
->method('info'); |
||||
|
||||
$this->assertNull($runner->run($process, new \SplObjectStorage(), true)); |
||||
} |
||||
|
||||
public function testRunSuccessFullProcessWithHandlers() |
||||
{ |
||||
$logger = $this->createLoggerMock(); |
||||
$runner = $this->getProcessRunner($logger); |
||||
|
||||
$capturedCallback = null; |
||||
|
||||
$process = $this->createProcessMock(1, true, '--helloworld--', "Kikoo Romain", null, true); |
||||
$process->expects($this->once()) |
||||
->method('run') |
||||
->with($this->isInstanceOf('Closure')) |
||||
->will($this->returnCallback(function ($callback) use (&$capturedCallback) { |
||||
$capturedCallback = $callback; |
||||
})); |
||||
|
||||
$logger |
||||
->expects($this->never()) |
||||
->method('error'); |
||||
$logger |
||||
->expects($this->exactly(2)) |
||||
->method('info'); |
||||
|
||||
$listener = new TestListener(); |
||||
$storage = new \SplObjectStorage(); |
||||
$storage->attach($listener); |
||||
|
||||
$capturedType = $capturedData = null; |
||||
|
||||
$listener->on('received', function ($type, $data) use (&$capturedType, &$capturedData) { |
||||
$capturedData = $data; |
||||
$capturedType = $type; |
||||
}); |
||||
|
||||
$this->assertEquals('Kikoo Romain', $runner->run($process, $storage, false)); |
||||
|
||||
$type = 'err'; |
||||
$data = 'data'; |
||||
|
||||
$capturedCallback($type, $data); |
||||
|
||||
$this->assertEquals($data, $capturedData); |
||||
$this->assertEquals($type, $capturedType); |
||||
} |
||||
} |
||||
|
||||
class TestListener extends EventEmitter implements ListenerInterface |
||||
{ |
||||
public function handle($type, $data) |
||||
{ |
||||
return $this->emit('received', array($type, $data)); |
||||
} |
||||
|
||||
public function forwardedEvents() |
||||
{ |
||||
return array(); |
||||
} |
||||
} |
||||
@ -0,0 +1,4 @@ |
||||
<?php |
||||
|
||||
$loader = require __DIR__.'/../vendor/autoload.php'; |
||||
$loader->add('Alchemy\Tests', __DIR__); |
||||
@ -0,0 +1,7 @@ |
||||
<?php |
||||
|
||||
// autoload.php generated by Composer |
||||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php'; |
||||
|
||||
return ComposerAutoloaderInit75f7ea26a11f6be21d13acba7a2d0249::getLoader(); |
||||