Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/apps.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2013-04-16 16:13:10 +0400
committerLukas Reschke <lukas@statuscode.ch>2013-04-16 16:13:10 +0400
commite04288c5589a9d87bc0e72a49921427de5a697f0 (patch)
tree89ffe7b86042f43ef53bc3bf3547ecabe0735dcb /files_videoviewer
parenta6c6538212190c8ed7587430108d4a1942bf2302 (diff)
Bump MediaElement.js to 2.11.3
Diffstat (limited to 'files_videoviewer')
-rwxr-xr-xfiles_videoviewer/js/flashmediaelement.swfbin28648 -> 28644 bytes
-rwxr-xr-xfiles_videoviewer/js/mediaelement-and-player.js50
-rwxr-xr-xfiles_videoviewer/js/mediaelement-and-player.min.js58
-rwxr-xr-xfiles_videoviewer/mediaelement/src/flash/FlashMediaElement.as2
-rwxr-xr-xfiles_videoviewer/mediaelement/src/flash/HtmlMediaEvent.as30
-rwxr-xr-xfiles_videoviewer/mediaelement/src/flash/htmlelements/AudioElement.as333
-rwxr-xr-xfiles_videoviewer/mediaelement/src/flash/htmlelements/IMediaElement.as36
-rwxr-xr-xfiles_videoviewer/mediaelement/src/flash/htmlelements/VideoElement.as2
-rwxr-xr-xfiles_videoviewer/mediaelement/src/flash/htmlelements/YouTubeElement.as2
-rwxr-xr-xfiles_videoviewer/mediaelement/src/js/me-header.js2
-rwxr-xr-xfiles_videoviewer/mediaelement/src/js/me-namespace.js2
-rwxr-xr-xfiles_videoviewer/mediaelement/src/js/me-shim.js4
-rwxr-xr-xfiles_videoviewer/mediaelement/src/js/me-utility.js42
13 files changed, 496 insertions, 67 deletions
diff --git a/files_videoviewer/js/flashmediaelement.swf b/files_videoviewer/js/flashmediaelement.swf
index d2464bfe2..9832d7b98 100755
--- a/files_videoviewer/js/flashmediaelement.swf
+++ b/files_videoviewer/js/flashmediaelement.swf
Binary files differ
diff --git a/files_videoviewer/js/mediaelement-and-player.js b/files_videoviewer/js/mediaelement-and-player.js
index 96da675df..d52868f67 100755
--- a/files_videoviewer/js/mediaelement-and-player.js
+++ b/files_videoviewer/js/mediaelement-and-player.js
@@ -7,7 +7,7 @@
* 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-2012, John Dyer (http://j.hn)
+* Copyright 2010-2013, John Dyer (http://j.hn)
* License: MIT
*
*/
@@ -15,7 +15,7 @@
var mejs = mejs || {};
// version number
-mejs.version = '2.11.1';
+mejs.version = '2.11.3';
// player number (for missing, same id attr)
mejs.meIndex = 0;
@@ -56,29 +56,47 @@ mejs.Utility = {
var
i = 0,
j,
- path = '',
- name = '',
- pos,
- script,
+ codePath = '',
+ testname = '',
+ slashPos,
+ filenamePos,
+ scriptUrl,
+ scriptPath,
+ scriptFilename,
scripts = document.getElementsByTagName('script'),
il = scripts.length,
jl = scriptNames.length;
-
+
+ // go through all <script> tags
for (; i < il; i++) {
- script = scripts[i].src;
+ scriptUrl = scripts[i].src;
+ slashPos = scriptUrl.lastIndexOf('/');
+ if (slashPos > -1) {
+ scriptFilename = scriptUrl.substring(slashPos + 1);
+ scriptPath = scriptUrl.substring(0, slashPos + 1);
+ } else {
+ scriptFilename = scriptUrl;
+ scriptPath = '';
+ }
+
+ // see if any <script> tags have a file name that matches the
for (j = 0; j < jl; j++) {
- name = scriptNames[j];
- pos = script.indexOf(name);
- if (pos > -1 && pos == script.length - name.length) {
- path = script.substring(0, pos);
+ testname = scriptNames[j];
+ filenamePos = scriptFilename.indexOf(testname);
+ if (filenamePos > -1) {
+ codePath = scriptPath;
break;
}
}
- if (path !== '') {
+
+ // if we found a path, then break and return it
+ if (codePath !== '') {
break;
}
}
- return path;
+
+ // send the best path back
+ return codePath;
},
secondsToTimeCode: function(time, forceHours, showFrameCount, fps) {
//add framecount
@@ -1384,7 +1402,7 @@ mejs.YouTubeApi = {
loadIframeApi: function() {
if (!this.isIframeStarted) {
var tag = document.createElement('script');
- tag.src = "http://www.youtube.com/player_api";
+ tag.src = "//www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
this.isIframeStarted = true;
@@ -1502,7 +1520,7 @@ mejs.YouTubeApi = {
*/
var specialIEContainer,
- youtubeUrl = 'http://www.youtube.com/apiplayer?enablejsapi=1&amp;playerapiid=' + settings.pluginId + '&amp;version=3&amp;autoplay=0&amp;controls=0&amp;modestbranding=1&loop=0';
+ youtubeUrl = '//www.youtube.com/apiplayer?enablejsapi=1&amp;playerapiid=' + settings.pluginId + '&amp;version=3&amp;autoplay=0&amp;controls=0&amp;modestbranding=1&loop=0';
if (mejs.MediaFeatures.isIE) {
diff --git a/files_videoviewer/js/mediaelement-and-player.min.js b/files_videoviewer/js/mediaelement-and-player.min.js
index 6bf5667c6..7266fae81 100755
--- a/files_videoviewer/js/mediaelement-and-player.min.js
+++ b/files_videoviewer/js/mediaelement-and-player.min.js
@@ -7,24 +7,24 @@
* 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-2012, John Dyer (http://j.hn)
+* Copyright 2010-2013, John Dyer (http://j.hn)
* License: MIT
*
-*/var mejs=mejs||{};mejs.version="2.11.1";mejs.meIndex=0;
+*/var mejs=mejs||{};mejs.version="2.11.3";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("&amp;").split("<").join("&lt;").split('"').join("&quot;")},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="",g,f,h=document.getElementsByTagName("script"),l=h.length,j=a.length;b<l;b++){f=h[b].src;for(c=0;c<j;c++){e=a[c];g=f.indexOf(e);
-if(g>-1&&g==f.length-e.length){d=f.substring(0,g);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,g=Math.floor(a/60)%60,f=Math.floor(a%60);a=Math.floor((a%1*d).toFixed(3));return(b||e>0?(e<10?"0"+e:e)+":":"")+(g<10?"0"+g:g)+":"+(f<10?"0"+f:f)+(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),g=parseInt(a[2],10),f=0,h=0;if(c)f=parseInt(a[3])/d;return h=b*3600+e*60+g+f},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=
+mejs.Utility={encodeUrl:function(a){return encodeURIComponent(a)},escapeHTML:function(a){return a.toString().split("&").join("&amp;").split("<").join("&lt;").split('"').join("&quot;")},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],g;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(g=new ActiveXObject(c))e=d(g)}catch(f){}return e}};
+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,g,f){for(;d.isVersionSupported(e[0]+"."+e[1]+"."+e[2]+"."+e[3]);)e[g]+=f;e[g]-=f};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,g=["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.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;a.svg=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect;for(c=0;c<g.length;c++)e=document.createElement(g[c]);a.supportsMediaTag=typeof e.canPlayType!=="undefined"||a.isBustedAndroid;a.hasSemiNativeFullScreen=typeof e.webkitEnterFullscreen!=="undefined";a.hasWebkitNativeFullScreen=typeof e.webkitRequestFullScreen!=="undefined";
+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.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;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;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(f){if(a.hasWebkitNativeFullScreen)f.webkitRequestFullScreen();else a.hasMozNativeFullScreen&&f.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();
+else if(e.webkitRequestFullScreen)return b.webkitIsFullScreen};a.requestFullScreen=function(g){if(a.hasWebkitNativeFullScreen)g.webkitRequestFullScreen();else a.hasMozNativeFullScreen&&g.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=
@@ -38,30 +38,30 @@ mejs.MediaPluginBridge={pluginMediaElements:{},htmlMediaElements:{},registerPlug
b.pluginApi=b.pluginElement.Content.MediaElementJS}b.pluginApi!=null&&b.success&&b.success(b,c)}},fireEvent:function(a,b,c){var d,e;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,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(),g=e==="audio"||e==="video",f=g?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];f=typeof f=="undefined"||f===null||f==""?null:f;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,g,f);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 g=[],f,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")g.push({type:b.type,url:e});else for(f=0;f<b.type.length;f++)g.push({type:b.type[f],url:e});else if(e!==null){l=this.formatType(e,a.getAttribute("type"));g.push({type:l,url:e})}else for(f=0;f<a.childNodes.length;f++){h=a.childNodes[f];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)g.push({type:l,url:e})}}if(!d&&g.length>0&&g[0].url!==null&&this.getTypeFromFile(g[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")){if(!d){f=document.createElement(j.isVideo?
-"video":"audio");a.parentNode.insertBefore(f,a);a.style.display="none";j.htmlMediaElement=a=f}for(f=0;f<g.length;f++)if(a.canPlayType(g[f].type).replace(/no/,"")!==""||a.canPlayType(g[f].type.replace(/mp3/,"mpeg")).replace(/no/,"")!==""){j.method="native";j.url=g[f].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(f=0;f<g.length;f++){l=g[f].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=g[f].url;return j}}}}if(b.mode==="auto_plugin"&&j.method==="native")return j;if(j.method===""&&g.length>0)j.url=g[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(g){}e.innerHTML=
-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,g){c=a.htmlMediaElement;var f=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){f=b.videoWidth>0?b.videoWidth:c.getAttribute("width")!==null?c.getAttribute("width"):b.defaultVideoWidth;h=b.videoHeight>0?b.videoHeight:c.getAttribute("height")!==null?c.getAttribute("height"):b.defaultVideoHeight;f=mejs.Utility.encodeUrl(f);h=mejs.Utility.encodeUrl(h)}else if(b.enablePluginDebug){f=
-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="+f,"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");g&&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="'+f+'" height="'+h+'" class="mejs-shim"><param name="initParams" value="'+
+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")){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=
+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.videoWidth>0?b.videoWidth:c.getAttribute("width")!==null?c.getAttribute("width"):b.defaultVideoWidth;h=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="'+f+'" height="'+h+'" class="mejs-shim"><param name="movie" value="'+b.pluginPath+b.flashName+"?x="+new Date+'" /><param name="flashvars" value="'+d.join("&amp;")+'" /><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="'+f+'" 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:f};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="'+f+'" height="'+h+'" frameborder="0" class="mejs-shim"></iframe>'}c.style.display="none";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="http://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,
+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("&amp;")+'" /><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";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="http://www.youtube.com/apiplayer?enablejsapi=1&amp;playerapiid="+a.pluginId+"&amp;version=3&amp;autoplay=0&amp;controls=0&amp;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="'+
+a;var b,c="//www.youtube.com/apiplayer?enablejsapi=1&amp;playerapiid="+a.pluginId+"&amp;version=3&amp;autoplay=0&amp;controls=0&amp;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:{strings:{}},methods:{}};c.locale.getLanguage=function(){return{language:navigator.language}};c.locale.INIT_LANGUAGE=c.locale.getLanguage();c.methods.checkPlain=function(d){var e,g,f={"&":"&amp;",'"':"&quot;","<":"&lt;",">":"&gt;"};d=String(d);for(e in f)if(f.hasOwnProperty(e)){g=RegExp(e,"g");d=d.replace(g,f[e])}return d};c.methods.formatString=function(d,e){for(var g in e){switch(g.charAt(0)){case "@":e[g]=c.methods.checkPlain(e[g]);break;case "!":break;default:e[g]=
-'<em class="placeholder">'+c.methods.checkPlain(e[g])+"</em>"}d=d.replace(g,e[g])}return d};c.methods.t=function(d,e,g){if(c.locale.strings&&c.locale.strings[g.context]&&c.locale.strings[g.context][d])d=c.locale.strings[g.context][d];if(e)d=c.methods.formatString(d,e);return d};c.t=function(d,e,g){if(typeof d==="string"&&d.length>0){var f=c.locale.getLanguage();g=g||{context:f.language};return c.methods.t(d,e,g)}else throw{name:"InvalidArgumentException",message:"First argument is either not a string or empty."};
+(function(a,b){var c={locale:{strings:{}},methods:{}};c.locale.getLanguage=function(){return{language:navigator.language}};c.locale.INIT_LANGUAGE=c.locale.getLanguage();c.methods.checkPlain=function(d){var e,f,g={"&":"&amp;",'"':"&quot;","<":"&lt;",">":"&gt;"};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.language};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){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);
/*!
diff --git a/files_videoviewer/mediaelement/src/flash/FlashMediaElement.as b/files_videoviewer/mediaelement/src/flash/FlashMediaElement.as
index 46899894c..d644aa787 100755
--- a/files_videoviewer/mediaelement/src/flash/FlashMediaElement.as
+++ b/files_videoviewer/mediaelement/src/flash/FlashMediaElement.as
@@ -1 +1 @@
-package { import flash.display.*; import flash.events.*; import flash.media.*; import flash.net.*; import flash.text.*; import flash.system.*; import flash.media.Video; import flash.net.NetConnection; import flash.net.NetStream; import flash.geom.ColorTransform; import flash.filters.DropShadowFilter; import flash.utils.Timer; import flash.external.ExternalInterface; import flash.geom.Rectangle; import htmlelements.IMediaElement; import htmlelements.VideoElement; import htmlelements.AudioElement; import htmlelements.YouTubeElement; public class FlashMediaElement extends MovieClip { private var _mediaUrl:String; private var _autoplay:Boolean; private var _preload:String; private var _debug:Boolean; private var _isVideo:Boolean; private var _video:DisplayObject; private var _timerRate:Number; private var _stageWidth:Number; private var _stageHeight:Number; private var _enableSmoothing:Boolean; private var _allowedPluginDomain:String; private var _isFullScreen:Boolean = false; private var _startVolume:Number; private var _controlStyle:String; private var _autoHide:Boolean = true; private var _streamer:String = ""; private var _enablePseudoStreaming:Boolean; private var _pseudoStreamingStartQueryParam:String; // native video size (from meta data) private var _nativeVideoWidth:Number = 0; private var _nativeVideoHeight:Number = 0; // visual elements private var _output:TextField; private var _fullscreenButton:SimpleButton; // media private var _mediaElement:IMediaElement; // connection to fullscreen private var _connection:LocalConnection; private var _connectionName:String; //private var fullscreen_btn:SimpleButton; // CONTROLS private var _alwaysShowControls:Boolean; private var _controlBar:MovieClip; private var _controlBarBg:MovieClip; private var _scrubBar:MovieClip; private var _scrubTrack:MovieClip; private var _scrubOverlay:MovieClip; private var _scrubLoaded:MovieClip; private var _hoverTime:MovieClip; private var _hoverTimeText:TextField; private var _playButton:SimpleButton; private var _pauseButton:SimpleButton; private var _duration:TextField; private var _currentTime:TextField; private var _fullscreenIcon:SimpleButton; private var _volumeMuted:SimpleButton; private var _volumeUnMuted:SimpleButton; private var _scrubTrackColor:String; private var _scrubBarColor:String; private var _scrubLoadedColor:String; // IDLE Timer for mouse for showing/hiding controls private var _inactiveTime:int; private var _timer:Timer; private var _idleTime:int; private var _isMouseActive:Boolean private var _isOverStage:Boolean = false; // security checkes private var securityIssue:Boolean = false; // When SWF parameters contain illegal characters private var directAccess:Boolean = false; // When SWF visited directly with no parameters (or when security issue detected) public function FlashMediaElement() { // show allow this player to be called from a different domain than the HTML page hosting the player Security.allowDomain("*"); // check for security issues (borrowed from jPLayer) checkFlashVars(loaderInfo.parameters); // add debug output _output = new TextField(); _output.textColor = 0xeeeeee; _output.width = stage.stageWidth - 100; _output.height = stage.stageHeight; _output.multiline = true; _output.wordWrap = true; _output.border = false; _output.filters = [new DropShadowFilter(1, 0x000000, 45, 1, 2, 2, 1)]; _output.text = "Initializing...\n"; addChild(_output); _output.visible = securityIssue; if (securityIssue) { _output.text = "WARNING: Security issue detected. Player stopped."; return; } // get parameters var params:Object = LoaderInfo(this.root.loaderInfo).parameters; _mediaUrl = (params['file'] != undefined) ? String(params['file']) : ""; _autoplay = (params['autoplay'] != undefined) ? (String(params['autoplay']) == "true") : false; _debug = (params['debug'] != undefined) ? (String(params['debug']) == "true") : false; _isVideo = (params['isvideo'] != undefined) ? ((String(params['isvideo']) == "false") ? false : true ) : true; _timerRate = (params['timerrate'] != undefined) ? (parseInt(params['timerrate'], 10)) : 250; _alwaysShowControls = (params['controls'] != undefined) ? (String(params['controls']) == "true") : false; _enableSmoothing = (params['smoothing'] != undefined) ? (String(params['smoothing']) == "true") : false; _startVolume = (params['startvolume'] != undefined) ? (parseFloat(params['startvolume'])) : 0.8; _preload = (params['preload'] != undefined) ? params['preload'] : "none"; _controlStyle = (params['controlstyle'] != undefined) ? (String(params['controlstyle'])) : ""; // blank or "floating" _autoHide = (params['autohide'] != undefined) ? (String(params['autohide'])) : true; _scrubTrackColor = (params['scrubtrackcolor'] != undefined) ? (String(params['scrubtrackcolor'])) : "0x333333"; _scrubBarColor = (params['scrubbarcolor'] != undefined) ? (String(params['scrubbarcolor'])) : "0xefefef"; _scrubLoadedColor = (params['scrubloadedcolor'] != undefined) ? (String(params['scrubloadedcolor'])) : "0x3CACC8"; _enablePseudoStreaming = (params['pseudostreaming'] != undefined) ? (String(params['pseudostreaming']) == "true") : false; _pseudoStreamingStartQueryParam = (params['pseudostreamstart'] != undefined) ? (String(params['pseudostreamstart'])) : "start"; _streamer = (params['flashstreamer'] != undefined) ? (String(params['flashstreamer'])) : ""; _output.visible = _debug; if (isNaN(_timerRate)) _timerRate = 250; // setup stage and player sizes/scales stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; _stageWidth = stage.stageWidth; _stageHeight = stage.stageHeight; //_autoplay = true; //_mediaUrl = "http://mediafiles.dts.edu/chapel/mp4/20100609.mp4"; //_alwaysShowControls = true; //_mediaUrl = "../media/Parades-PastLives.mp3"; //_mediaUrl = "../media/echo-hereweare.mp4"; //_mediaUrl = "http://video.ted.com/talks/podcast/AlGore_2006_480.mp4"; //_mediaUrl = "rtmp://stream2.france24.yacast.net/france24_live/en/f24_liveen"; //_mediaUrl = "http://www.youtube.com/watch?feature=player_embedded&v=yyWWXSwtPP0"; // hosea //_mediaUrl = "http://www.youtube.com/watch?feature=player_embedded&v=m5VDDJlsD6I"; // railer with notes //_alwaysShowControls = true; //_debug=true; // position and hide _fullscreenButton = getChildByName("fullscreen_btn") as SimpleButton; //_fullscreenButton.visible = false; _fullscreenButton.alpha = 0; _fullscreenButton.addEventListener(MouseEvent.CLICK, fullscreenClick, false); _fullscreenButton.x = stage.stageWidth - _fullscreenButton.width; _fullscreenButton.y = stage.stageHeight - _fullscreenButton.height; // create media element if (_isVideo) { if (_mediaUrl.indexOf("youtube.com") > -1 || _mediaUrl.indexOf("youtu.be") > -1) { //Security.allowDomain("http://www.youtube.com"); _mediaElement = new YouTubeElement(this, _autoplay, _preload, _timerRate, _startVolume); _video = (_mediaElement as YouTubeElement).player; // these are set and then used once the player is loaded (_mediaElement as YouTubeElement).initWidth = _stageWidth; (_mediaElement as YouTubeElement).initHeight = _stageHeight; } else { _mediaElement = new VideoElement(this, _autoplay, _preload, _timerRate, _startVolume, _streamer); _video = (_mediaElement as VideoElement).video; _video.width = _stageWidth; _video.height = _stageHeight; (_video as Video).smoothing = _enableSmoothing; (_mediaElement as VideoElement).setReference(this); (_mediaElement as VideoElement).setPseudoStreaming(_enablePseudoStreaming); (_mediaElement as VideoElement).setPseudoStreamingStartParam(_pseudoStreamingStartQueryParam); //_video.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO; addChild(_video); } } else { //var player2:AudioDecoder = new com.automatastudios.audio.audiodecoder.AudioDecoder(); _mediaElement = new AudioElement(this, _autoplay, _preload, _timerRate, _startVolume); } // controls! _controlBar = getChildByName("controls_mc") as MovieClip; _controlBarBg = _controlBar.getChildByName("controls_bg_mc") as MovieClip; _scrubTrack = _controlBar.getChildByName("scrubTrack") as MovieClip; _scrubBar = _controlBar.getChildByName("scrubBar") as MovieClip; _scrubOverlay = _controlBar.getChildByName("scrubOverlay") as MovieClip; _scrubLoaded = _controlBar.getChildByName("scrubLoaded") as MovieClip; _scrubOverlay.buttonMode = true; _scrubOverlay.useHandCursor = true applyColor(_scrubTrack, _scrubTrackColor); applyColor(_scrubBar, _scrubBarColor); applyColor(_scrubLoaded, _scrubLoadedColor); _fullscreenIcon = _controlBar.getChildByName("fullscreenIcon") as SimpleButton; // New fullscreenIcon for new fullscreen floating controls //if(_alwaysShowControls && _controlStyle.toUpperCase()=="FLOATING") { _fullscreenIcon.addEventListener(MouseEvent.CLICK, fullScreenIconClick, false); //} _volumeMuted = _controlBar.getChildByName("muted_mc") as SimpleButton; _volumeUnMuted = _controlBar.getChildByName("unmuted_mc") as SimpleButton; _volumeMuted.addEventListener(MouseEvent.CLICK, toggleVolume, false); _volumeUnMuted.addEventListener(MouseEvent.CLICK, toggleVolume, false); _playButton = _controlBar.getChildByName("play_btn") as SimpleButton; _playButton.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) { _mediaElement.play(); }); _pauseButton = _controlBar.getChildByName("pause_btn") as SimpleButton; _pauseButton.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) { _mediaElement.pause(); }); _pauseButton.visible = false; _duration = _controlBar.getChildByName("duration_txt") as TextField; _currentTime = _controlBar.getChildByName("currentTime_txt") as TextField; _hoverTime = _controlBar.getChildByName("hoverTime") as MovieClip; _hoverTimeText = _hoverTime.getChildByName("hoverTime_txt") as TextField; _hoverTime.visible=false; _hoverTime.y=(_hoverTime.height/2)+1; _hoverTime.x=0; // Add new timeline scrubber events _scrubOverlay.addEventListener(MouseEvent.MOUSE_MOVE, scrubMove); _scrubOverlay.addEventListener(MouseEvent.CLICK, scrubClick); _scrubOverlay.addEventListener(MouseEvent.MOUSE_OVER, scrubOver); _scrubOverlay.addEventListener(MouseEvent.MOUSE_OUT, scrubOut); if (_autoHide) { // && _alwaysShowControls) { // Add mouse activity for show/hide of controls stage.addEventListener(Event.MOUSE_LEAVE, mouseActivityLeave); stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseActivityMove); _inactiveTime = 2500; _timer = new Timer(_inactiveTime) _timer.addEventListener(TimerEvent.TIMER, idleTimer); _timer.start(); // set } if(_alwaysShowControls) { if(_startVolume<=0) { trace("INITIAL VOLUME: "+_startVolume+" MUTED"); _volumeMuted.visible=true; _volumeUnMuted.visible=false; } else { trace("INITIAL VOLUME: "+_startVolume+" UNMUTED"); _volumeMuted.visible=false; _volumeUnMuted.visible=true; } } _controlBar.visible = _alwaysShowControls; setControlDepth(); _output.appendText("stage: " + stage.stageWidth + "x" + stage.stageHeight + "\n"); _output.appendText("file: " + _mediaUrl + "\n"); _output.appendText("autoplay: " + _autoplay.toString() + "\n"); _output.appendText("preload: " + _preload.toString() + "\n"); _output.appendText("isvideo: " + _isVideo.toString() + "\n"); _output.appendText("smoothing: " + _enableSmoothing.toString() + "\n"); _output.appendText("timerrate: " + _timerRate.toString() + "\n"); _output.appendText("displayState: " +(stage.hasOwnProperty("displayState")).toString() + "\n"); // attach javascript _output.appendText("ExternalInterface.available: " + ExternalInterface.available.toString() + "\n"); _output.appendText("ExternalInterface.objectID: " + ((ExternalInterface.objectID != null)? ExternalInterface.objectID.toString() : "null") + "\n"); if (_mediaUrl != "") { _mediaElement.setSrc(_mediaUrl); } positionControls(); // Fire this once just to set the width on some dynamically sized scrub bar items; _scrubBar.scaleX=0; _scrubLoaded.scaleX=0; if (ExternalInterface.available) { // && !_alwaysShowControls _output.appendText("Adding callbacks...\n"); try { if (ExternalInterface.objectID != null && ExternalInterface.objectID.toString() != "") { // add HTML media methods ExternalInterface.addCallback("playMedia", playMedia); ExternalInterface.addCallback("loadMedia", loadMedia); ExternalInterface.addCallback("pauseMedia", pauseMedia); ExternalInterface.addCallback("stopMedia", stopMedia); ExternalInterface.addCallback("setSrc", setSrc); ExternalInterface.addCallback("setCurrentTime", setCurrentTime); ExternalInterface.addCallback("setVolume", setVolume); ExternalInterface.addCallback("setMuted", setMuted); ExternalInterface.addCallback("setFullscreen", setFullscreen); ExternalInterface.addCallback("setVideoSize", setVideoSize); ExternalInterface.addCallback("positionFullscreenButton", positionFullscreenButton); ExternalInterface.addCallback("hideFullscreenButton", hideFullscreenButton); // fire init method ExternalInterface.call("mejs.MediaPluginBridge.initPlugin", ExternalInterface.objectID); } _output.appendText("Success...\n"); } catch (error:SecurityError) { _output.appendText("A SecurityError occurred: " + error.message + "\n"); } catch (error:Error) { _output.appendText("An Error occurred: " + error.message + "\n"); } } if (_preload != "none") { _mediaElement.load(); if (_autoplay) { _mediaElement.play(); } } else if (_autoplay) { _mediaElement.load(); _mediaElement.play(); } // listen for resize stage.addEventListener(Event.RESIZE, resizeHandler); // send click events up to javascript stage.addEventListener(MouseEvent.CLICK, stageClicked); // resize stage.addEventListener(FullScreenEvent.FULL_SCREEN, stageFullScreenChanged); } public function setControlDepth():void { // put these on top addChild(_output); addChild(_controlBar); addChild(_fullscreenButton); } // borrowed from jPLayer // https://github.com/happyworm/jPlayer/blob/e8ca190f7f972a6a421cb95f09e138720e40ed6d/actionscript/Jplayer.as#L228 private function checkFlashVars(p:Object):void { var i:Number = 0; for each (var s:String in p) { if (isIllegalChar(s)) { securityIssue = true; // Illegal char found } i++; } if(i === 0 || securityIssue) { directAccess = true; } } private function isIllegalChar(s:String):Boolean { var illegals:String = "' \" ( ) { } * + / \\ < > = document"; if(Boolean(s)) { // Otherwise exception if parameter null. for each (var illegal:String in illegals.split(' ')) { if(s.indexOf(illegal) >= 0) { return true; // Illegal char found } } } return false; } // START: Controls and events function mouseActivityMove(event:MouseEvent):void { // if mouse is in the video area if (_autoHide && (mouseX>=0 && mouseX<=stage.stageWidth) && (mouseY>=0 && mouseY<=stage.stageHeight)) { // This could be move to a nice fade at some point... _controlBar.visible = (_alwaysShowControls || _isFullScreen); _isMouseActive = true; _idleTime = 0; _timer.reset(); _timer.start() } } function mouseActivityLeave(event:Event):void { if (_autoHide) { _isOverStage = false; // This could be move to a nice fade at some point... _controlBar.visible = false; _isMouseActive = false; _idleTime = 0; _timer.reset(); _timer.stop(); } } function idleTimer(event:TimerEvent):void { if (_autoHide) { // This could be move to a nice fade at some point... _controlBar.visible = false; _isMouseActive = false; _idleTime += _inactiveTime; _idleTime = 0; _timer.reset(); _timer.stop(); } } function scrubMove(event:MouseEvent):void { //if (_alwaysShowControls) { if (_hoverTime.visible) { var seekBarPosition:Number = ((event.localX / _scrubTrack.width) *_mediaElement.duration())*_scrubTrack.scaleX; var hoverPos:Number = (seekBarPosition / _mediaElement.duration()) *_scrubTrack.scaleX; if (_isFullScreen) { _hoverTime.x=event.target.parent.mouseX; } else { _hoverTime.x=mouseX; } _hoverTime.y = _scrubBar.y - (_hoverTime.height/2); _hoverTimeText.text = secondsToTimeCode(seekBarPosition); } //} //trace(event); } function scrubOver(event:MouseEvent):void { _hoverTime.y = _scrubBar.y-(_hoverTime.height/2)+1; _hoverTime.visible = true; trace(event); } function scrubOut(event:MouseEvent):void { _hoverTime.y = _scrubBar.y+(_hoverTime.height/2)+1; _hoverTime.visible = false; //_hoverTime.x=0; //trace(event); } function scrubClick(event:MouseEvent):void { //trace(event); var seekBarPosition:Number = ((event.localX / _scrubTrack.width) *_mediaElement.duration())*_scrubTrack.scaleX; var tmp:Number = (_mediaElement.currentTime()/_mediaElement.duration())*_scrubTrack.width; var canSeekToPosition:Boolean = _scrubLoaded.scaleX > (seekBarPosition / _mediaElement.duration()) *_scrubTrack.scaleX; //var canSeekToPosition:Boolean = true; /* amountLoaded = ns.bytesLoaded / ns.bytesTotal; loader.loadbar._width = amountLoaded * 208.9; loader.scrub._x = ns.time / duration * 208.9; */ trace("seekBarPosition:"+seekBarPosition, "CanSeekToPosition: "+canSeekToPosition); if (seekBarPosition>0 && seekBarPosition<_mediaElement.duration() && canSeekToPosition) { _mediaElement.setCurrentTime(seekBarPosition); } } function toggleVolume(event:MouseEvent):void { trace(event.currentTarget.name); switch(event.currentTarget.name) { case "muted_mc": setMuted(false); break; case "unmuted_mc": setMuted(true); break; } } function toggleVolumeIcons(volume:Number) { if(volume<=0) { _volumeMuted.visible = true; _volumeUnMuted.visible = false; } else { _volumeMuted.visible = false; _volumeUnMuted.visible = true; } } public function positionControls(forced:Boolean=false) { if ( _controlStyle.toUpperCase() == "FLOATING" && _isFullScreen) { trace("CONTROLS: floating"); _hoverTime.y=(_hoverTime.height/2)+1; _hoverTime.x=0; _controlBarBg.width = 300; _controlBarBg.height = 93; //_controlBarBg.x = (stage.stageWidth/2) - (_controlBarBg.width/2); //_controlBarBg.y = stage.stageHeight - 300; _pauseButton.scaleX = _playButton.scaleX=3.5; _pauseButton.scaleY= _playButton.scaleY=3.5; // center the play button and make it big and at the top _pauseButton.x = _playButton.x = (_controlBarBg.width/2)-(_playButton.width/2)+7; _pauseButton.y = _playButton.y = _controlBarBg.height-_playButton.height-(14) _controlBar.x = (stage.stageWidth/2) -150; _controlBar.y = stage.stageHeight - _controlBar.height-100; // reposition the time and duration items _duration.x = _controlBarBg.width - _duration.width - 10; _duration.y = _controlBarBg.height - _duration.height -7; //_currentTime.x = _controlBarBg.width - _duration.width - 10 - _currentTime.width - 10; _currentTime.x = 5 _currentTime.y= _controlBarBg.height - _currentTime.height-7; _fullscreenIcon.x = _controlBarBg.width - _fullscreenIcon.width - 7; _fullscreenIcon.y = 7; _volumeMuted.x = _volumeUnMuted.x = 7; _volumeMuted.y = _volumeUnMuted.y = 7; _scrubLoaded.x = _scrubBar.x = _scrubOverlay.x = _scrubTrack.x =_currentTime.x+_currentTime.width+7; _scrubLoaded.y = _scrubBar.y = _scrubOverlay.y = _scrubTrack.y=_controlBarBg.height-_scrubTrack.height-10; _scrubBar.width = _scrubOverlay.width = _scrubTrack.width = (_duration.x-_duration.width-14); } else { trace("CONTROLS: normal, original"); /* // Original style bottom display _hoverTime.y=(_hoverTime.height/2)+1; _hoverTime.x=0; _controlBarBg.width = stage.stageWidth; _controlBar.y = stage.stageHeight - _controlBar.height; _duration.x = stage.stageWidth - _duration.width - 10; //_currentTime.x = stage.stageWidth - _duration.width - 10 - _currentTime.width - 10; _currentTime.x = _playButton.x+_playButton.width; _scrubTrack.width = (_duration.x-_duration.width-10)-_duration.width+10; _scrubOverlay.width = _scrubTrack.width; _scrubBar.width = _scrubTrack.width; */ // FLOATING MODE BOTTOM DISPLAY - similar to normal trace("THAT WAY!"); _hoverTime.y=(_hoverTime.height/2)+1; _hoverTime.x=0; _controlBarBg.width = stage.stageWidth; _controlBarBg.height = 30; _controlBarBg.y=0; _controlBarBg.x=0; // _controlBarBg.x = 0; // _controlBarBg.y = stage.stageHeight - _controlBar.height; _pauseButton.scaleX = _playButton.scaleX=1; _pauseButton.scaleY = _playButton.scaleY=1; _pauseButton.x = _playButton.x = 7; _pauseButton.y = _playButton.y = _controlBarBg.height-_playButton.height-2; //_currentTime.x = stage.stageWidth - _duration.width - 10 - _currentTime.width - 10; _currentTime.x = _playButton.x+_playButton.width; _fullscreenIcon.x = _controlBarBg.width - _fullscreenIcon.width - 7; _fullscreenIcon.y = 8; _volumeMuted.x = _volumeUnMuted.x = _fullscreenIcon.x - _volumeMuted.width - 10; _volumeMuted.y = _volumeUnMuted.y = 10; _duration.x = _volumeMuted.x - _volumeMuted.width - _duration.width + 5; _duration.y = _currentTime.y = _controlBarBg.height - _currentTime.height - 7; _scrubLoaded.x = _scrubBar.x = _scrubOverlay.x = _scrubTrack.x = _currentTime.x + _currentTime.width + 10; _scrubLoaded.y = _scrubBar.y = _scrubOverlay.y = _scrubTrack.y = _controlBarBg.height - _scrubTrack.height - 9; _scrubBar.width = _scrubOverlay.width = _scrubTrack.width = (_duration.x-_duration.width-10)-_duration.width+5; _controlBar.x = 0; _controlBar.y = stage.stageHeight - _controlBar.height; } } // END: Controls function stageClicked(e:MouseEvent):void { //_output.appendText("click: " + e.stageX.toString() +","+e.stageY.toString() + "\n"); if (e.target == stage) { sendEvent("click", ""); } } function resizeHandler(e:Event):void { //_video.scaleX = stage.stageWidth / _stageWidth; //_video.scaleY = stage.stageHeight / _stageHeight; //positionControls(); repositionVideo(); } // START: Fullscreen function enterFullscreen() { _output.appendText("enterFullscreen()\n"); var screenRectangle:Rectangle = new Rectangle(0, 0, flash.system.Capabilities.screenResolutionX, flash.system.Capabilities.screenResolutionY); stage.fullScreenSourceRect = screenRectangle; stage.displayState = StageDisplayState.FULL_SCREEN; repositionVideo(true); positionControls(); updateControls(HtmlMediaEvent.FULLSCREENCHANGE); _controlBar.visible = true; _isFullScreen = true; } function exitFullscreen() { stage.displayState = StageDisplayState.NORMAL; _controlBar.visible = false; _isFullScreen = false; } function setFullscreen(gofullscreen:Boolean) { _output.appendText("setFullscreen: " + gofullscreen.toString() + "\n"); try { //_fullscreenButton.visible = false; if (gofullscreen) { enterFullscreen(); } else { exitFullscreen(); } } catch (error:Error) { // show the button when the security error doesn't let it work //_fullscreenButton.visible = true; _fullscreenButton.alpha = 1; _isFullScreen = false; _output.appendText("error setting fullscreen: " + error.message.toString() + "\n"); } } // control bar button/icon function fullScreenIconClick(e:MouseEvent) { try { _controlBar.visible = true; setFullscreen(!_isFullScreen); repositionVideo(_isFullScreen); } catch (error:Error) { } } // special floating fullscreen icon function fullscreenClick(e:MouseEvent) { //_fullscreenButton.visible = false; _fullscreenButton.alpha = 0 try { _controlBar.visible = true; setFullscreen(true); repositionVideo(true); positionControls(); } catch (error:Error) { } } function stageFullScreenChanged(e:FullScreenEvent) { _output.appendText("fullscreen event: " + e.fullScreen.toString() + "\n"); //_fullscreenButton.visible = false; _fullscreenButton.alpha = 0; _isFullScreen = e.fullScreen; sendEvent(HtmlMediaEvent.FULLSCREENCHANGE, "isFullScreen:" + e.fullScreen ); if (!e.fullScreen) { _controlBar.visible = _alwaysShowControls; } } // END: Fullscreen // START: external interface function playMedia() { _output.appendText("play\n"); _mediaElement.play(); } function loadMedia() { _output.appendText("load\n"); _mediaElement.load(); } function pauseMedia() { _output.appendText("pause\n"); _mediaElement.pause(); } function setSrc(url:String) { _output.appendText("setSrc: " + url + "\n"); _mediaElement.setSrc(url); } function stopMedia() { _output.appendText("stop\n"); _mediaElement.stop(); } function setCurrentTime(time:Number) { _output.appendText("seek: " + time.toString() + "\n"); _mediaElement.setCurrentTime(time); } function setVolume(volume:Number) { _output.appendText("volume: " + volume.toString() + "\n"); _mediaElement.setVolume(volume); toggleVolumeIcons(volume); } function setMuted(muted:Boolean) { _output.appendText("muted: " + muted.toString() + "\n"); _mediaElement.setMuted(muted); toggleVolumeIcons(_mediaElement.getVolume()); } function setVideoSize(width:Number, height:Number) { _output.appendText("setVideoSize: " + width.toString() + "," + height.toString() + "\n"); _stageWidth = width; _stageHeight = height; if (_video != null) { repositionVideo(); positionControls(); //_fullscreenButton.x = stage.stageWidth - _fullscreenButton.width - 10; _output.appendText("result: " + _video.width.toString() + "," + _video.height.toString() + "\n"); } } function positionFullscreenButton(x:Number, y:Number, visibleAndAbove:Boolean ) { _output.appendText("position FS: " + x.toString() + "x" + y.toString() + "\n"); // bottom corner /* _fullscreenButton.x = stage.stageWidth - _fullscreenButton.width _fullscreenButton.y = stage.stageHeight - _fullscreenButton.height; */ // position just above if (visibleAndAbove) { _fullscreenButton.x = x+1; _fullscreenButton.y = y - _fullscreenButton.height+1; } else { _fullscreenButton.x = x; _fullscreenButton.y = y; } // check for oversizing if ((_fullscreenButton.x + _fullscreenButton.width) > stage.stageWidth) _fullscreenButton.x = stage.stageWidth - _fullscreenButton.width; // show it! if (visibleAndAbove) { _fullscreenButton.alpha = 1; } } function hideFullscreenButton() { //_fullscreenButton.visible = false; _fullscreenButton.alpha = 0; } // END: external interface function repositionVideo(fullscreen:Boolean = false):void { _output.appendText("positioning video\n"); if (_mediaElement is VideoElement) { if (isNaN(_nativeVideoWidth) || isNaN(_nativeVideoHeight) || _nativeVideoWidth <= 0 || _nativeVideoHeight <= 0) { _output.appendText("ERR: I dont' have the native dimension\n"); return; } // calculate ratios var stageRatio, nativeRatio; _video.x = 0; _video.y = 0; if(fullscreen == true) { stageRatio = flash.system.Capabilities.screenResolutionX/flash.system.Capabilities.screenResolutionY; nativeRatio = _nativeVideoWidth/_nativeVideoHeight; // adjust size and position if (nativeRatio > stageRatio) { _mediaElement.setSize(flash.system.Capabilities.screenResolutionX, _nativeVideoHeight * flash.system.Capabilities.screenResolutionX / _nativeVideoWidth); _video.y = flash.system.Capabilities.screenResolutionY/2 - _video.height/2; } else if (stageRatio > nativeRatio) { _mediaElement.setSize(_nativeVideoWidth * flash.system.Capabilities.screenResolutionY / _nativeVideoHeight, flash.system.Capabilities.screenResolutionY); _video.x = flash.system.Capabilities.screenResolutionX/2 - _video.width/2; } else if (stageRatio == nativeRatio) { _mediaElement.setSize(flash.system.Capabilities.screenResolutionX, flash.system.Capabilities.screenResolutionY); } } else { stageRatio = _stageWidth/_stageHeight; nativeRatio = _nativeVideoWidth/_nativeVideoHeight; // adjust size and position if (nativeRatio > stageRatio) { _mediaElement.setSize(_stageWidth, _nativeVideoHeight * _stageWidth / _nativeVideoWidth); _video.y = _stageHeight/2 - _video.height/2; } else if (stageRatio > nativeRatio) { _mediaElement.setSize( _nativeVideoWidth * _stageHeight / _nativeVideoHeight, _stageHeight); _video.x = _stageWidth/2 - _video.width/2; } else if (stageRatio == nativeRatio) { _mediaElement.setSize(_stageWidth, _stageHeight); } } } else if (_mediaElement is YouTubeElement) { if(fullscreen == true) { _mediaElement.setSize(flash.system.Capabilities.screenResolutionX, flash.system.Capabilities.screenResolutionY); } else { _mediaElement.setSize(_stageWidth, _stageHeight); } } positionControls(); } // SEND events to JavaScript public function sendEvent(eventName:String, eventValues:String) { // special video event if (eventName == HtmlMediaEvent.LOADEDMETADATA && _isVideo) { _output.appendText("METADATA RECEIVED: "); try { if (_mediaElement is VideoElement) { _nativeVideoWidth = (_mediaElement as VideoElement).videoWidth; _nativeVideoHeight = (_mediaElement as VideoElement).videoHeight; } } catch (e:Error) { _output.appendText(e.toString() + "\n"); } _output.appendText(_nativeVideoWidth.toString() + "x" + _nativeVideoHeight.toString() + "\n"); if(stage.displayState == "fullScreen" ) { setVideoSize(_nativeVideoWidth, _nativeVideoHeight); repositionVideo(true); } else { repositionVideo(); } } updateControls(eventName); //trace((_mediaElement.duration()*1).toString() + " / " + (_mediaElement.currentTime()*1).toString()); //trace("CurrentProgress:"+_mediaElement.currentProgress()); if (ExternalInterface.objectID != null && ExternalInterface.objectID.toString() != "") { //_output.appendText("event:" + eventName + " : " + eventValues); //trace("event", eventName, eventValues); if (eventValues == null) eventValues == ""; if (_isVideo) { eventValues += (eventValues != "" ? "," : "") + "isFullScreen:" + _isFullScreen; } eventValues = "{" + eventValues + "}"; /* OLD DIRECT METHOD ExternalInterface.call( "function(id, name) { mejs.MediaPluginBridge.fireEvent(id,name," + eventValues + "); }", ExternalInterface.objectID, eventName); */ // use set timeout for performance reasons //if (!_alwaysShowControls) { ExternalInterface.call("setTimeout", "mejs.MediaPluginBridge.fireEvent('" + ExternalInterface.objectID + "','" + eventName + "'," + eventValues + ")",0); //} } } function updateControls(eventName:String):void { //trace("updating controls"); try { // update controls switch (eventName) { case "pause": case "paused": case "ended": _playButton.visible = true; _pauseButton.visible = false; break; case "play": case "playing": _playButton.visible = false; _pauseButton.visible = true; break; } if (eventName == HtmlMediaEvent.TIMEUPDATE || eventName == HtmlMediaEvent.PROGRESS || eventName == HtmlMediaEvent.FULLSCREENCHANGE) { //_duration.text = (_mediaElement.duration()*1).toString(); _duration.text = secondsToTimeCode(_mediaElement.duration()); //_currentTime.text = (_mediaElement.currentTime()*1).toString(); _currentTime.text = secondsToTimeCode(_mediaElement.currentTime()); var pct:Number = (_mediaElement.currentTime() / _mediaElement.duration()) *_scrubTrack.scaleX; _scrubBar.scaleX = pct; _scrubLoaded.scaleX = (_mediaElement.currentProgress()*_scrubTrack.scaleX)/100; } } catch (error:Error) { trace("error: " + error.toString()); } } // START: utility function secondsToTimeCode(seconds:Number):String { var timeCode:String = ""; seconds = Math.round(seconds); var minutes:Number = Math.floor(seconds / 60); timeCode = (minutes >= 10) ? minutes.toString() : "0" + minutes.toString(); seconds = Math.floor(seconds % 60); timeCode += ":" + ((seconds >= 10) ? seconds.toString() : "0" + seconds.toString()); return timeCode; //minutes.toString() + ":" + seconds.toString(); } function applyColor(item:Object, color:String):void { var myColor:ColorTransform = item.transform.colorTransform; myColor.color = Number(color); item.transform.colorTransform = myColor; } // END: utility } } \ No newline at end of file
+package { import flash.display.*; import flash.events.*; import flash.media.*; import flash.net.*; import flash.text.*; import flash.system.*; import flash.media.Video; import flash.net.NetConnection; import flash.net.NetStream; import flash.geom.ColorTransform; import flash.filters.DropShadowFilter; import flash.utils.Timer; import flash.external.ExternalInterface; import flash.geom.Rectangle; import htmlelements.IMediaElement; import htmlelements.VideoElement; import htmlelements.AudioElement; import htmlelements.YouTubeElement; public class FlashMediaElement extends MovieClip { private var _mediaUrl:String; private var _autoplay:Boolean; private var _preload:String; private var _debug:Boolean; private var _isVideo:Boolean; private var _video:DisplayObject; private var _timerRate:Number; private var _stageWidth:Number; private var _stageHeight:Number; private var _enableSmoothing:Boolean; private var _allowedPluginDomain:String; private var _isFullScreen:Boolean = false; private var _startVolume:Number; private var _controlStyle:String; private var _autoHide:Boolean = true; private var _streamer:String = ""; private var _enablePseudoStreaming:Boolean; private var _pseudoStreamingStartQueryParam:String; // native video size (from meta data) private var _nativeVideoWidth:Number = 0; private var _nativeVideoHeight:Number = 0; // visual elements private var _output:TextField; private var _fullscreenButton:SimpleButton; // media private var _mediaElement:IMediaElement; // connection to fullscreen private var _connection:LocalConnection; private var _connectionName:String; //private var fullscreen_btn:SimpleButton; // CONTROLS private var _alwaysShowControls:Boolean; private var _controlBar:MovieClip; private var _controlBarBg:MovieClip; private var _scrubBar:MovieClip; private var _scrubTrack:MovieClip; private var _scrubOverlay:MovieClip; private var _scrubLoaded:MovieClip; private var _hoverTime:MovieClip; private var _hoverTimeText:TextField; private var _playButton:SimpleButton; private var _pauseButton:SimpleButton; private var _duration:TextField; private var _currentTime:TextField; private var _fullscreenIcon:SimpleButton; private var _volumeMuted:SimpleButton; private var _volumeUnMuted:SimpleButton; private var _scrubTrackColor:String; private var _scrubBarColor:String; private var _scrubLoadedColor:String; // IDLE Timer for mouse for showing/hiding controls private var _inactiveTime:int; private var _timer:Timer; private var _idleTime:int; private var _isMouseActive:Boolean private var _isOverStage:Boolean = false; // security checkes private var securityIssue:Boolean = false; // When SWF parameters contain illegal characters private var directAccess:Boolean = false; // When SWF visited directly with no parameters (or when security issue detected) public function FlashMediaElement() { // show allow this player to be called from a different domain than the HTML page hosting the player Security.allowDomain("*"); // check for security issues (borrowed from jPLayer) checkFlashVars(loaderInfo.parameters); // add debug output _output = new TextField(); _output.textColor = 0xeeeeee; _output.width = stage.stageWidth - 100; _output.height = stage.stageHeight; _output.multiline = true; _output.wordWrap = true; _output.border = false; _output.filters = [new DropShadowFilter(1, 0x000000, 45, 1, 2, 2, 1)]; _output.text = "Initializing...\n"; addChild(_output); _output.visible = securityIssue; if (securityIssue) { _output.text = "WARNING: Security issue detected. Player stopped."; return; } // get parameters var params:Object = LoaderInfo(this.root.loaderInfo).parameters; _mediaUrl = (params['file'] != undefined) ? String(params['file']) : ""; _autoplay = (params['autoplay'] != undefined) ? (String(params['autoplay']) == "true") : false; _debug = (params['debug'] != undefined) ? (String(params['debug']) == "true") : false; _isVideo = (params['isvideo'] != undefined) ? ((String(params['isvideo']) == "false") ? false : true ) : true; _timerRate = (params['timerrate'] != undefined) ? (parseInt(params['timerrate'], 10)) : 250; _alwaysShowControls = (params['controls'] != undefined) ? (String(params['controls']) == "true") : false; _enableSmoothing = (params['smoothing'] != undefined) ? (String(params['smoothing']) == "true") : false; _startVolume = (params['startvolume'] != undefined) ? (parseFloat(params['startvolume'])) : 0.8; _preload = (params['preload'] != undefined) ? params['preload'] : "none"; _controlStyle = (params['controlstyle'] != undefined) ? (String(params['controlstyle'])) : ""; // blank or "floating" _autoHide = (params['autohide'] != undefined) ? (String(params['autohide'])) : true; _scrubTrackColor = (params['scrubtrackcolor'] != undefined) ? (String(params['scrubtrackcolor'])) : "0x333333"; _scrubBarColor = (params['scrubbarcolor'] != undefined) ? (String(params['scrubbarcolor'])) : "0xefefef"; _scrubLoadedColor = (params['scrubloadedcolor'] != undefined) ? (String(params['scrubloadedcolor'])) : "0x3CACC8"; _enablePseudoStreaming = (params['pseudostreaming'] != undefined) ? (String(params['pseudostreaming']) == "true") : false; _pseudoStreamingStartQueryParam = (params['pseudostreamstart'] != undefined) ? (String(params['pseudostreamstart'])) : "start"; _streamer = (params['flashstreamer'] != undefined) ? (String(params['flashstreamer'])) : ""; _output.visible = _debug; if (isNaN(_timerRate)) _timerRate = 250; // setup stage and player sizes/scales stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; _stageWidth = stage.stageWidth; _stageHeight = stage.stageHeight; //_autoplay = true; //_mediaUrl = "http://mediafiles.dts.edu/chapel/mp4/20100609.mp4"; //_alwaysShowControls = true; //_mediaUrl = "../media/Parades-PastLives.mp3"; //_mediaUrl = "../media/echo-hereweare.mp4"; //_mediaUrl = "http://video.ted.com/talks/podcast/AlGore_2006_480.mp4"; //_mediaUrl = "rtmp://stream2.france24.yacast.net/france24_live/en/f24_liveen"; //_mediaUrl = "http://www.youtube.com/watch?feature=player_embedded&v=yyWWXSwtPP0"; // hosea //_mediaUrl = "http://www.youtube.com/watch?feature=player_embedded&v=m5VDDJlsD6I"; // railer with notes //_alwaysShowControls = true; //_debug=true; // position and hide _fullscreenButton = getChildByName("fullscreen_btn") as SimpleButton; //_fullscreenButton.visible = false; _fullscreenButton.alpha = 0; _fullscreenButton.addEventListener(MouseEvent.CLICK, fullscreenClick, false); _fullscreenButton.x = stage.stageWidth - _fullscreenButton.width; _fullscreenButton.y = stage.stageHeight - _fullscreenButton.height; // create media element if (_isVideo) { if (_mediaUrl.indexOf("youtube.com") > -1 || _mediaUrl.indexOf("youtu.be") > -1) { //Security.allowDomain("http://www.youtube.com"); _mediaElement = new YouTubeElement(this, _autoplay, _preload, _timerRate, _startVolume); _video = (_mediaElement as YouTubeElement).player; // these are set and then used once the player is loaded (_mediaElement as YouTubeElement).initWidth = _stageWidth; (_mediaElement as YouTubeElement).initHeight = _stageHeight; } else { _mediaElement = new VideoElement(this, _autoplay, _preload, _timerRate, _startVolume, _streamer); _video = (_mediaElement as VideoElement).video; _video.width = _stageWidth; _video.height = _stageHeight; (_video as Video).smoothing = _enableSmoothing; (_mediaElement as VideoElement).setReference(this); (_mediaElement as VideoElement).setPseudoStreaming(_enablePseudoStreaming); (_mediaElement as VideoElement).setPseudoStreamingStartParam(_pseudoStreamingStartQueryParam); //_video.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO; addChild(_video); } } else { //var player2:AudioDecoder = new com.automatastudios.audio.audiodecoder.AudioDecoder(); _mediaElement = new AudioElement(this, _autoplay, _preload, _timerRate, _startVolume); } // controls! _controlBar = getChildByName("controls_mc") as MovieClip; _controlBarBg = _controlBar.getChildByName("controls_bg_mc") as MovieClip; _scrubTrack = _controlBar.getChildByName("scrubTrack") as MovieClip; _scrubBar = _controlBar.getChildByName("scrubBar") as MovieClip; _scrubOverlay = _controlBar.getChildByName("scrubOverlay") as MovieClip; _scrubLoaded = _controlBar.getChildByName("scrubLoaded") as MovieClip; _scrubOverlay.buttonMode = true; _scrubOverlay.useHandCursor = true applyColor(_scrubTrack, _scrubTrackColor); applyColor(_scrubBar, _scrubBarColor); applyColor(_scrubLoaded, _scrubLoadedColor); _fullscreenIcon = _controlBar.getChildByName("fullscreenIcon") as SimpleButton; // New fullscreenIcon for new fullscreen floating controls //if(_alwaysShowControls && _controlStyle.toUpperCase()=="FLOATING") { _fullscreenIcon.addEventListener(MouseEvent.CLICK, fullScreenIconClick, false); //} _volumeMuted = _controlBar.getChildByName("muted_mc") as SimpleButton; _volumeUnMuted = _controlBar.getChildByName("unmuted_mc") as SimpleButton; _volumeMuted.addEventListener(MouseEvent.CLICK, toggleVolume, false); _volumeUnMuted.addEventListener(MouseEvent.CLICK, toggleVolume, false); _playButton = _controlBar.getChildByName("play_btn") as SimpleButton; _playButton.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) { _mediaElement.play(); }); _pauseButton = _controlBar.getChildByName("pause_btn") as SimpleButton; _pauseButton.addEventListener(MouseEvent.CLICK, function(e:MouseEvent) { _mediaElement.pause(); }); _pauseButton.visible = false; _duration = _controlBar.getChildByName("duration_txt") as TextField; _currentTime = _controlBar.getChildByName("currentTime_txt") as TextField; _hoverTime = _controlBar.getChildByName("hoverTime") as MovieClip; _hoverTimeText = _hoverTime.getChildByName("hoverTime_txt") as TextField; _hoverTime.visible=false; _hoverTime.y=(_hoverTime.height/2)+1; _hoverTime.x=0; // Add new timeline scrubber events _scrubOverlay.addEventListener(MouseEvent.MOUSE_MOVE, scrubMove); _scrubOverlay.addEventListener(MouseEvent.CLICK, scrubClick); _scrubOverlay.addEventListener(MouseEvent.MOUSE_OVER, scrubOver); _scrubOverlay.addEventListener(MouseEvent.MOUSE_OUT, scrubOut); if (_autoHide) { // && _alwaysShowControls) { // Add mouse activity for show/hide of controls stage.addEventListener(Event.MOUSE_LEAVE, mouseActivityLeave); stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseActivityMove); _inactiveTime = 2500; _timer = new Timer(_inactiveTime) _timer.addEventListener(TimerEvent.TIMER, idleTimer); _timer.start(); // set } if(_alwaysShowControls) { if(_startVolume<=0) { trace("INITIAL VOLUME: "+_startVolume+" MUTED"); _volumeMuted.visible=true; _volumeUnMuted.visible=false; } else { trace("INITIAL VOLUME: "+_startVolume+" UNMUTED"); _volumeMuted.visible=false; _volumeUnMuted.visible=true; } } _controlBar.visible = _alwaysShowControls; setControlDepth(); _output.appendText("stage: " + stage.stageWidth + "x" + stage.stageHeight + "\n"); _output.appendText("file: " + _mediaUrl + "\n"); _output.appendText("autoplay: " + _autoplay.toString() + "\n"); _output.appendText("preload: " + _preload.toString() + "\n"); _output.appendText("isvideo: " + _isVideo.toString() + "\n"); _output.appendText("smoothing: " + _enableSmoothing.toString() + "\n"); _output.appendText("timerrate: " + _timerRate.toString() + "\n"); _output.appendText("displayState: " +(stage.hasOwnProperty("displayState")).toString() + "\n"); // attach javascript _output.appendText("ExternalInterface.available: " + ExternalInterface.available.toString() + "\n"); _output.appendText("ExternalInterface.objectID: " + ((ExternalInterface.objectID != null)? ExternalInterface.objectID.toString() : "null") + "\n"); if (_mediaUrl != "") { _mediaElement.setSrc(_mediaUrl); } positionControls(); // Fire this once just to set the width on some dynamically sized scrub bar items; _scrubBar.scaleX=0; _scrubLoaded.scaleX=0; if (ExternalInterface.available) { // && !_alwaysShowControls _output.appendText("Adding callbacks...\n"); try { if (ExternalInterface.objectID != null && ExternalInterface.objectID.toString() != "") { // add HTML media methods ExternalInterface.addCallback("playMedia", playMedia); ExternalInterface.addCallback("loadMedia", loadMedia); ExternalInterface.addCallback("pauseMedia", pauseMedia); ExternalInterface.addCallback("stopMedia", stopMedia); ExternalInterface.addCallback("setSrc", setSrc); ExternalInterface.addCallback("setCurrentTime", setCurrentTime); ExternalInterface.addCallback("setVolume", setVolume); ExternalInterface.addCallback("setMuted", setMuted); ExternalInterface.addCallback("setFullscreen", setFullscreen); ExternalInterface.addCallback("setVideoSize", setVideoSize); ExternalInterface.addCallback("positionFullscreenButton", positionFullscreenButton); ExternalInterface.addCallback("hideFullscreenButton", hideFullscreenButton); // fire init method ExternalInterface.call("mejs.MediaPluginBridge.initPlugin", ExternalInterface.objectID); } _output.appendText("Success...\n"); } catch (error:SecurityError) { _output.appendText("A SecurityError occurred: " + error.message + "\n"); } catch (error:Error) { _output.appendText("An Error occurred: " + error.message + "\n"); } } if (_preload != "none") { _mediaElement.load(); if (_autoplay) { _mediaElement.play(); } } else if (_autoplay) { _mediaElement.load(); _mediaElement.play(); } // listen for resize stage.addEventListener(Event.RESIZE, resizeHandler); // send click events up to javascript stage.addEventListener(MouseEvent.CLICK, stageClicked); // resize stage.addEventListener(FullScreenEvent.FULL_SCREEN, stageFullScreenChanged); } public function setControlDepth():void { // put these on top addChild(_output); addChild(_controlBar); addChild(_fullscreenButton); } // borrowed from jPLayer // https://github.com/happyworm/jPlayer/blob/e8ca190f7f972a6a421cb95f09e138720e40ed6d/actionscript/Jplayer.as#L228 private function checkFlashVars(p:Object):void { var i:Number = 0; for each (var s:String in p) { if (isIllegalChar(s)) { securityIssue = true; // Illegal char found } i++; } if(i === 0 || securityIssue) { directAccess = true; } } private function isIllegalChar(s:String):Boolean { var illegals:String = "' \" ( ) { } * + \\ < >"; if(Boolean(s)) { // Otherwise exception if parameter null. for each (var illegal:String in illegals.split(' ')) { if(s.indexOf(illegal) >= 0) { return true; // Illegal char found } } } return false; } // START: Controls and events function mouseActivityMove(event:MouseEvent):void { // if mouse is in the video area if (_autoHide && (mouseX>=0 && mouseX<=stage.stageWidth) && (mouseY>=0 && mouseY<=stage.stageHeight)) { // This could be move to a nice fade at some point... _controlBar.visible = (_alwaysShowControls || _isFullScreen); _isMouseActive = true; _idleTime = 0; _timer.reset(); _timer.start() } } function mouseActivityLeave(event:Event):void { if (_autoHide) { _isOverStage = false; // This could be move to a nice fade at some point... _controlBar.visible = false; _isMouseActive = false; _idleTime = 0; _timer.reset(); _timer.stop(); } } function idleTimer(event:TimerEvent):void { if (_autoHide) { // This could be move to a nice fade at some point... _controlBar.visible = false; _isMouseActive = false; _idleTime += _inactiveTime; _idleTime = 0; _timer.reset(); _timer.stop(); } } function scrubMove(event:MouseEvent):void { //if (_alwaysShowControls) { if (_hoverTime.visible) { var seekBarPosition:Number = ((event.localX / _scrubTrack.width) *_mediaElement.duration())*_scrubTrack.scaleX; var hoverPos:Number = (seekBarPosition / _mediaElement.duration()) *_scrubTrack.scaleX; if (_isFullScreen) { _hoverTime.x=event.target.parent.mouseX; } else { _hoverTime.x=mouseX; } _hoverTime.y = _scrubBar.y - (_hoverTime.height/2); _hoverTimeText.text = secondsToTimeCode(seekBarPosition); } //} //trace(event); } function scrubOver(event:MouseEvent):void { _hoverTime.y = _scrubBar.y-(_hoverTime.height/2)+1; _hoverTime.visible = true; trace(event); } function scrubOut(event:MouseEvent):void { _hoverTime.y = _scrubBar.y+(_hoverTime.height/2)+1; _hoverTime.visible = false; //_hoverTime.x=0; //trace(event); } function scrubClick(event:MouseEvent):void { //trace(event); var seekBarPosition:Number = ((event.localX / _scrubTrack.width) *_mediaElement.duration())*_scrubTrack.scaleX; var tmp:Number = (_mediaElement.currentTime()/_mediaElement.duration())*_scrubTrack.width; var canSeekToPosition:Boolean = _scrubLoaded.scaleX > (seekBarPosition / _mediaElement.duration()) *_scrubTrack.scaleX; //var canSeekToPosition:Boolean = true; /* amountLoaded = ns.bytesLoaded / ns.bytesTotal; loader.loadbar._width = amountLoaded * 208.9; loader.scrub._x = ns.time / duration * 208.9; */ trace("seekBarPosition:"+seekBarPosition, "CanSeekToPosition: "+canSeekToPosition); if (seekBarPosition>0 && seekBarPosition<_mediaElement.duration() && canSeekToPosition) { _mediaElement.setCurrentTime(seekBarPosition); } } function toggleVolume(event:MouseEvent):void { trace(event.currentTarget.name); switch(event.currentTarget.name) { case "muted_mc": setMuted(false); break; case "unmuted_mc": setMuted(true); break; } } function toggleVolumeIcons(volume:Number) { if(volume<=0) { _volumeMuted.visible = true; _volumeUnMuted.visible = false; } else { _volumeMuted.visible = false; _volumeUnMuted.visible = true; } } public function positionControls(forced:Boolean=false) { if ( _controlStyle.toUpperCase() == "FLOATING" && _isFullScreen) { trace("CONTROLS: floating"); _hoverTime.y=(_hoverTime.height/2)+1; _hoverTime.x=0; _controlBarBg.width = 300; _controlBarBg.height = 93; //_controlBarBg.x = (stage.stageWidth/2) - (_controlBarBg.width/2); //_controlBarBg.y = stage.stageHeight - 300; _pauseButton.scaleX = _playButton.scaleX=3.5; _pauseButton.scaleY= _playButton.scaleY=3.5; // center the play button and make it big and at the top _pauseButton.x = _playButton.x = (_controlBarBg.width/2)-(_playButton.width/2)+7; _pauseButton.y = _playButton.y = _controlBarBg.height-_playButton.height-(14) _controlBar.x = (stage.stageWidth/2) -150; _controlBar.y = stage.stageHeight - _controlBar.height-100; // reposition the time and duration items _duration.x = _controlBarBg.width - _duration.width - 10; _duration.y = _controlBarBg.height - _duration.height -7; //_currentTime.x = _controlBarBg.width - _duration.width - 10 - _currentTime.width - 10; _currentTime.x = 5 _currentTime.y= _controlBarBg.height - _currentTime.height-7; _fullscreenIcon.x = _controlBarBg.width - _fullscreenIcon.width - 7; _fullscreenIcon.y = 7; _volumeMuted.x = _volumeUnMuted.x = 7; _volumeMuted.y = _volumeUnMuted.y = 7; _scrubLoaded.x = _scrubBar.x = _scrubOverlay.x = _scrubTrack.x =_currentTime.x+_currentTime.width+7; _scrubLoaded.y = _scrubBar.y = _scrubOverlay.y = _scrubTrack.y=_controlBarBg.height-_scrubTrack.height-10; _scrubBar.width = _scrubOverlay.width = _scrubTrack.width = (_duration.x-_duration.width-14); } else { trace("CONTROLS: normal, original"); /* // Original style bottom display _hoverTime.y=(_hoverTime.height/2)+1; _hoverTime.x=0; _controlBarBg.width = stage.stageWidth; _controlBar.y = stage.stageHeight - _controlBar.height; _duration.x = stage.stageWidth - _duration.width - 10; //_currentTime.x = stage.stageWidth - _duration.width - 10 - _currentTime.width - 10; _currentTime.x = _playButton.x+_playButton.width; _scrubTrack.width = (_duration.x-_duration.width-10)-_duration.width+10; _scrubOverlay.width = _scrubTrack.width; _scrubBar.width = _scrubTrack.width; */ // FLOATING MODE BOTTOM DISPLAY - similar to normal trace("THAT WAY!"); _hoverTime.y=(_hoverTime.height/2)+1; _hoverTime.x=0; _controlBarBg.width = stage.stageWidth; _controlBarBg.height = 30; _controlBarBg.y=0; _controlBarBg.x=0; // _controlBarBg.x = 0; // _controlBarBg.y = stage.stageHeight - _controlBar.height; _pauseButton.scaleX = _playButton.scaleX=1; _pauseButton.scaleY = _playButton.scaleY=1; _pauseButton.x = _playButton.x = 7; _pauseButton.y = _playButton.y = _controlBarBg.height-_playButton.height-2; //_currentTime.x = stage.stageWidth - _duration.width - 10 - _currentTime.width - 10; _currentTime.x = _playButton.x+_playButton.width; _fullscreenIcon.x = _controlBarBg.width - _fullscreenIcon.width - 7; _fullscreenIcon.y = 8; _volumeMuted.x = _volumeUnMuted.x = _fullscreenIcon.x - _volumeMuted.width - 10; _volumeMuted.y = _volumeUnMuted.y = 10; _duration.x = _volumeMuted.x - _volumeMuted.width - _duration.width + 5; _duration.y = _currentTime.y = _controlBarBg.height - _currentTime.height - 7; _scrubLoaded.x = _scrubBar.x = _scrubOverlay.x = _scrubTrack.x = _currentTime.x + _currentTime.width + 10; _scrubLoaded.y = _scrubBar.y = _scrubOverlay.y = _scrubTrack.y = _controlBarBg.height - _scrubTrack.height - 9; _scrubBar.width = _scrubOverlay.width = _scrubTrack.width = (_duration.x-_duration.width-10)-_duration.width+5; _controlBar.x = 0; _controlBar.y = stage.stageHeight - _controlBar.height; } } // END: Controls function stageClicked(e:MouseEvent):void { //_output.appendText("click: " + e.stageX.toString() +","+e.stageY.toString() + "\n"); if (e.target == stage) { sendEvent("click", ""); } } function resizeHandler(e:Event):void { //_video.scaleX = stage.stageWidth / _stageWidth; //_video.scaleY = stage.stageHeight / _stageHeight; //positionControls(); repositionVideo(); } // START: Fullscreen function enterFullscreen() { _output.appendText("enterFullscreen()\n"); var screenRectangle:Rectangle = new Rectangle(0, 0, flash.system.Capabilities.screenResolutionX, flash.system.Capabilities.screenResolutionY); stage.fullScreenSourceRect = screenRectangle; stage.displayState = StageDisplayState.FULL_SCREEN; repositionVideo(true); positionControls(); updateControls(HtmlMediaEvent.FULLSCREENCHANGE); _controlBar.visible = true; _isFullScreen = true; } function exitFullscreen() { stage.displayState = StageDisplayState.NORMAL; _controlBar.visible = false; _isFullScreen = false; } function setFullscreen(gofullscreen:Boolean) { _output.appendText("setFullscreen: " + gofullscreen.toString() + "\n"); try { //_fullscreenButton.visible = false; if (gofullscreen) { enterFullscreen(); } else { exitFullscreen(); } } catch (error:Error) { // show the button when the security error doesn't let it work //_fullscreenButton.visible = true; _fullscreenButton.alpha = 1; _isFullScreen = false; _output.appendText("error setting fullscreen: " + error.message.toString() + "\n"); } } // control bar button/icon function fullScreenIconClick(e:MouseEvent) { try { _controlBar.visible = true; setFullscreen(!_isFullScreen); repositionVideo(_isFullScreen); } catch (error:Error) { } } // special floating fullscreen icon function fullscreenClick(e:MouseEvent) { //_fullscreenButton.visible = false; _fullscreenButton.alpha = 0 try { _controlBar.visible = true; setFullscreen(true); repositionVideo(true); positionControls(); } catch (error:Error) { } } function stageFullScreenChanged(e:FullScreenEvent) { _output.appendText("fullscreen event: " + e.fullScreen.toString() + "\n"); //_fullscreenButton.visible = false; _fullscreenButton.alpha = 0; _isFullScreen = e.fullScreen; sendEvent(HtmlMediaEvent.FULLSCREENCHANGE, "isFullScreen:" + e.fullScreen ); if (!e.fullScreen) { _controlBar.visible = _alwaysShowControls; } } // END: Fullscreen // START: external interface function playMedia() { _output.appendText("play\n"); _mediaElement.play(); } function loadMedia() { _output.appendText("load\n"); _mediaElement.load(); } function pauseMedia() { _output.appendText("pause\n"); _mediaElement.pause(); } function setSrc(url:String) { _output.appendText("setSrc: " + url + "\n"); _mediaElement.setSrc(url); } function stopMedia() { _output.appendText("stop\n"); _mediaElement.stop(); } function setCurrentTime(time:Number) { _output.appendText("seek: " + time.toString() + "\n"); _mediaElement.setCurrentTime(time); } function setVolume(volume:Number) { _output.appendText("volume: " + volume.toString() + "\n"); _mediaElement.setVolume(volume); toggleVolumeIcons(volume); } function setMuted(muted:Boolean) { _output.appendText("muted: " + muted.toString() + "\n"); _mediaElement.setMuted(muted); toggleVolumeIcons(_mediaElement.getVolume()); } function setVideoSize(width:Number, height:Number) { _output.appendText("setVideoSize: " + width.toString() + "," + height.toString() + "\n"); _stageWidth = width; _stageHeight = height; if (_video != null) { repositionVideo(); positionControls(); //_fullscreenButton.x = stage.stageWidth - _fullscreenButton.width - 10; _output.appendText("result: " + _video.width.toString() + "," + _video.height.toString() + "\n"); } } function positionFullscreenButton(x:Number, y:Number, visibleAndAbove:Boolean ) { _output.appendText("position FS: " + x.toString() + "x" + y.toString() + "\n"); // bottom corner /* _fullscreenButton.x = stage.stageWidth - _fullscreenButton.width _fullscreenButton.y = stage.stageHeight - _fullscreenButton.height; */ // position just above if (visibleAndAbove) { _fullscreenButton.x = x+1; _fullscreenButton.y = y - _fullscreenButton.height+1; } else { _fullscreenButton.x = x; _fullscreenButton.y = y; } // check for oversizing if ((_fullscreenButton.x + _fullscreenButton.width) > stage.stageWidth) _fullscreenButton.x = stage.stageWidth - _fullscreenButton.width; // show it! if (visibleAndAbove) { _fullscreenButton.alpha = 1; } } function hideFullscreenButton() { //_fullscreenButton.visible = false; _fullscreenButton.alpha = 0; } // END: external interface function repositionVideo(fullscreen:Boolean = false):void { _output.appendText("positioning video\n"); if (_mediaElement is VideoElement) { if (isNaN(_nativeVideoWidth) || isNaN(_nativeVideoHeight) || _nativeVideoWidth <= 0 || _nativeVideoHeight <= 0) { _output.appendText("ERR: I dont' have the native dimension\n"); return; } // calculate ratios var stageRatio, nativeRatio; _video.x = 0; _video.y = 0; if(fullscreen == true) { stageRatio = flash.system.Capabilities.screenResolutionX/flash.system.Capabilities.screenResolutionY; nativeRatio = _nativeVideoWidth/_nativeVideoHeight; // adjust size and position if (nativeRatio > stageRatio) { _mediaElement.setSize(flash.system.Capabilities.screenResolutionX, _nativeVideoHeight * flash.system.Capabilities.screenResolutionX / _nativeVideoWidth); _video.y = flash.system.Capabilities.screenResolutionY/2 - _video.height/2; } else if (stageRatio > nativeRatio) { _mediaElement.setSize(_nativeVideoWidth * flash.system.Capabilities.screenResolutionY / _nativeVideoHeight, flash.system.Capabilities.screenResolutionY); _video.x = flash.system.Capabilities.screenResolutionX/2 - _video.width/2; } else if (stageRatio == nativeRatio) { _mediaElement.setSize(flash.system.Capabilities.screenResolutionX, flash.system.Capabilities.screenResolutionY); } } else { stageRatio = _stageWidth/_stageHeight; nativeRatio = _nativeVideoWidth/_nativeVideoHeight; // adjust size and position if (nativeRatio > stageRatio) { _mediaElement.setSize(_stageWidth, _nativeVideoHeight * _stageWidth / _nativeVideoWidth); _video.y = _stageHeight/2 - _video.height/2; } else if (stageRatio > nativeRatio) { _mediaElement.setSize( _nativeVideoWidth * _stageHeight / _nativeVideoHeight, _stageHeight); _video.x = _stageWidth/2 - _video.width/2; } else if (stageRatio == nativeRatio) { _mediaElement.setSize(_stageWidth, _stageHeight); } } } else if (_mediaElement is YouTubeElement) { if(fullscreen == true) { _mediaElement.setSize(flash.system.Capabilities.screenResolutionX, flash.system.Capabilities.screenResolutionY); } else { _mediaElement.setSize(_stageWidth, _stageHeight); } } positionControls(); } // SEND events to JavaScript public function sendEvent(eventName:String, eventValues:String) { // special video event if (eventName == HtmlMediaEvent.LOADEDMETADATA && _isVideo) { _output.appendText("METADATA RECEIVED: "); try { if (_mediaElement is VideoElement) { _nativeVideoWidth = (_mediaElement as VideoElement).videoWidth; _nativeVideoHeight = (_mediaElement as VideoElement).videoHeight; } } catch (e:Error) { _output.appendText(e.toString() + "\n"); } _output.appendText(_nativeVideoWidth.toString() + "x" + _nativeVideoHeight.toString() + "\n"); if(stage.displayState == "fullScreen" ) { setVideoSize(_nativeVideoWidth, _nativeVideoHeight); repositionVideo(true); } else { repositionVideo(); } } updateControls(eventName); //trace((_mediaElement.duration()*1).toString() + " / " + (_mediaElement.currentTime()*1).toString()); //trace("CurrentProgress:"+_mediaElement.currentProgress()); if (ExternalInterface.objectID != null && ExternalInterface.objectID.toString() != "") { //_output.appendText("event:" + eventName + " : " + eventValues); //trace("event", eventName, eventValues); if (eventValues == null) eventValues == ""; if (_isVideo) { eventValues += (eventValues != "" ? "," : "") + "isFullScreen:" + _isFullScreen; } eventValues = "{" + eventValues + "}"; /* OLD DIRECT METHOD ExternalInterface.call( "function(id, name) { mejs.MediaPluginBridge.fireEvent(id,name," + eventValues + "); }", ExternalInterface.objectID, eventName); */ // use set timeout for performance reasons //if (!_alwaysShowControls) { ExternalInterface.call("setTimeout", "mejs.MediaPluginBridge.fireEvent('" + ExternalInterface.objectID + "','" + eventName + "'," + eventValues + ")",0); //} } } function updateControls(eventName:String):void { //trace("updating controls"); try { // update controls switch (eventName) { case "pause": case "paused": case "ended": _playButton.visible = true; _pauseButton.visible = false; break; case "play": case "playing": _playButton.visible = false; _pauseButton.visible = true; break; } if (eventName == HtmlMediaEvent.TIMEUPDATE || eventName == HtmlMediaEvent.PROGRESS || eventName == HtmlMediaEvent.FULLSCREENCHANGE) { //_duration.text = (_mediaElement.duration()*1).toString(); _duration.text = secondsToTimeCode(_mediaElement.duration()); //_currentTime.text = (_mediaElement.currentTime()*1).toString(); _currentTime.text = secondsToTimeCode(_mediaElement.currentTime()); var pct:Number = (_mediaElement.currentTime() / _mediaElement.duration()) *_scrubTrack.scaleX; _scrubBar.scaleX = pct; _scrubLoaded.scaleX = (_mediaElement.currentProgress()*_scrubTrack.scaleX)/100; } } catch (error:Error) { trace("error: " + error.toString()); } } // START: utility function secondsToTimeCode(seconds:Number):String { var timeCode:String = ""; seconds = Math.round(seconds); var minutes:Number = Math.floor(seconds / 60); timeCode = (minutes >= 10) ? minutes.toString() : "0" + minutes.toString(); seconds = Math.floor(seconds % 60); timeCode += ":" + ((seconds >= 10) ? seconds.toString() : "0" + seconds.toString()); return timeCode; //minutes.toString() + ":" + seconds.toString(); } function applyColor(item:Object, color:String):void { var myColor:ColorTransform = item.transform.colorTransform; myColor.color = Number(color); item.transform.colorTransform = myColor; } // END: utility } } \ No newline at end of file
diff --git a/files_videoviewer/mediaelement/src/flash/HtmlMediaEvent.as b/files_videoviewer/mediaelement/src/flash/HtmlMediaEvent.as
index 6210df116..d12c0fedf 100755
--- a/files_videoviewer/mediaelement/src/flash/HtmlMediaEvent.as
+++ b/files_videoviewer/mediaelement/src/flash/HtmlMediaEvent.as
@@ -1 +1,29 @@
-package { public class HtmlMediaEvent { public static var LOADED_DATA:String = "loadeddata"; public static var PROGRESS:String = "progress"; public static var TIMEUPDATE:String = "timeupdate"; public static var SEEKED:String = "seeked"; public static var PLAY:String = "play"; public static var PLAYING:String = "playing"; public static var PAUSE:String = "pause"; public static var LOADEDMETADATA:String = "loadedmetadata"; public static var ENDED:String = "ended"; public static var VOLUMECHANGE:String = "volumechange"; public static var STOP:String = "stop"; // new : 2/15/2011 public static var LOADSTART:String = "loadstart"; public static var CANPLAY:String = "canplay"; // new : 3/3/2011 public static var LOADEDDATA:String = "loadeddata"; // new : 4/12/2011 public static var SEEKING:String = "seeking"; // new : 1/2/2012 public static var FULLSCREENCHANGE:String = "fullscreenchange"; } } \ No newline at end of file
+package {
+
+ public class HtmlMediaEvent {
+
+ public static var LOADED_DATA:String = "loadeddata";
+ public static var PROGRESS:String = "progress";
+ public static var TIMEUPDATE:String = "timeupdate";
+ public static var SEEKED:String = "seeked";
+ public static var PLAY:String = "play";
+ public static var PLAYING:String = "playing";
+ public static var PAUSE:String = "pause";
+ public static var LOADEDMETADATA:String = "loadedmetadata";
+ public static var ENDED:String = "ended";
+ public static var VOLUMECHANGE:String = "volumechange";
+ public static var STOP:String = "stop";
+
+ // new : 2/15/2011
+ public static var LOADSTART:String = "loadstart";
+ public static var CANPLAY:String = "canplay";
+ // new : 3/3/2011
+ public static var LOADEDDATA:String = "loadeddata";
+
+ // new : 4/12/2011
+ public static var SEEKING:String = "seeking";
+
+ // new : 1/2/2012
+ public static var FULLSCREENCHANGE:String = "fullscreenchange";
+ }
+}
diff --git a/files_videoviewer/mediaelement/src/flash/htmlelements/AudioElement.as b/files_videoviewer/mediaelement/src/flash/htmlelements/AudioElement.as
index bf90e9b13..750599d4a 100755
--- a/files_videoviewer/mediaelement/src/flash/htmlelements/AudioElement.as
+++ b/files_videoviewer/mediaelement/src/flash/htmlelements/AudioElement.as
@@ -1 +1,332 @@
- package htmlelements { import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.ProgressEvent; import flash.events.TimerEvent; import flash.media.ID3Info; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundLoaderContext; import flash.media.SoundTransform; import flash.net.URLRequest; import flash.utils.Timer; /** * ... * @author DefaultUser (Tools -> Custom Arguments...) */ public class AudioElement implements IMediaElement { private var _sound:Sound; private var _soundTransform:SoundTransform; private var _soundChannel:SoundChannel; private var _soundLoaderContext:SoundLoaderContext; private var _volume:Number = 1; private var _preMuteVolume:Number = 0; private var _isMuted:Boolean = false; private var _isPaused:Boolean = true; private var _isEnded:Boolean = false; private var _isLoaded:Boolean = false; private var _currentTime:Number = 0; private var _duration:Number = 0; private var _bytesLoaded:Number = 0; private var _bytesTotal:Number = 0; private var _bufferedTime:Number = 0; private var _bufferingChanged:Boolean = false; private var _currentUrl:String = ""; private var _autoplay:Boolean = true; private var _preload:String = ""; private var _element:FlashMediaElement; private var _timer:Timer; private var _firedCanPlay:Boolean = false; public function setSize(width:Number, height:Number):void { // do nothing! } public function duration():Number { return _duration; } public function currentTime():Number { return _currentTime; } public function currentProgress():Number { return Math.round(_bytesLoaded/_bytesTotal*100); } public function AudioElement(element:FlashMediaElement, autoplay:Boolean, preload:String, timerRate:Number, startVolume:Number) { _element = element; _autoplay = autoplay; _volume = startVolume; _preload = preload; _timer = new Timer(timerRate); _timer.addEventListener(TimerEvent.TIMER, timerEventHandler); _soundTransform = new SoundTransform(_volume); _soundLoaderContext = new SoundLoaderContext(); } // events function progressHandler(e:ProgressEvent):void { _bytesLoaded = e.bytesLoaded; _bytesTotal = e.bytesTotal; // this happens too much to send every time //sendEvent(HtmlMediaEvent.PROGRESS); // so now we just trigger a flag and send with the timer _bufferingChanged = true; } function id3Handler(e:Event):void { sendEvent(HtmlMediaEvent.LOADEDMETADATA); try { var id3:ID3Info = _sound.id3; var obj = { type:'id3', album:id3.album, artist:id3.artist, comment:id3.comment, genre:id3.genre, songName:id3.songName, track:id3.track, year:id3.year } } catch (err:Error) {} } function timerEventHandler(e:TimerEvent) { _currentTime = _soundChannel.position/1000; // calculate duration var duration = Math.round(_sound.length * _sound.bytesTotal/_sound.bytesLoaded/100) / 10; // check to see if the estimated duration changed if (_duration != duration && !isNaN(duration)) { _duration = duration; sendEvent(HtmlMediaEvent.LOADEDMETADATA); } // check for progress if (_bufferingChanged) { sendEvent(HtmlMediaEvent.PROGRESS); _bufferingChanged = false; } // send timeupdate sendEvent(HtmlMediaEvent.TIMEUPDATE); // sometimes the ended event doesn't fire, here's a fake one if (_duration > 0 && _currentTime >= _duration-0.2) { handleEnded(); } } function soundCompleteHandler(e:Event) { handleEnded(); } function handleEnded():void { _timer.stop(); _currentTime = 0; _isEnded = true; sendEvent(HtmlMediaEvent.ENDED); } //events // METHODS public function setSrc(url:String):void { _currentUrl = url; _isLoaded = false; } public function load():void { if (_currentUrl == "") return; _sound = new Sound(); //sound.addEventListener(IOErrorEvent.IO_ERROR,errorHandler); _sound.addEventListener(ProgressEvent.PROGRESS,progressHandler); _sound.addEventListener(Event.ID3,id3Handler); _sound.load(new URLRequest(_currentUrl)); _currentTime = 0; sendEvent(HtmlMediaEvent.LOADSTART); _isLoaded = true; sendEvent(HtmlMediaEvent.LOADEDDATA); sendEvent(HtmlMediaEvent.CANPLAY); _firedCanPlay = true; if (_playAfterLoading) { _playAfterLoading = false; play(); } } private var _playAfterLoading:Boolean= false; public function play():void { if (!_isLoaded) { _playAfterLoading = true; load(); return; } _timer.stop(); _soundChannel = _sound.play(_currentTime*1000, 0, _soundTransform); _soundChannel.removeEventListener(Event.SOUND_COMPLETE, soundCompleteHandler); _soundChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler); _timer.start(); didStartPlaying(); } public function pause():void { _timer.stop(); if (_soundChannel != null) { _currentTime = _soundChannel.position/1000; _soundChannel.stop(); } _isPaused = true; sendEvent(HtmlMediaEvent.PAUSE); } public function stop():void { if (_timer != null) { _timer.stop(); } if (_soundChannel != null) { _soundChannel.stop(); _sound.close(); } unload(); sendEvent(HtmlMediaEvent.STOP); } public function setCurrentTime(pos:Number):void { sendEvent(HtmlMediaEvent.SEEKING); _timer.stop(); _currentTime = pos; _soundChannel.stop(); _sound.length _soundChannel = _sound.play(_currentTime * 1000, 0, _soundTransform); sendEvent(HtmlMediaEvent.SEEKED); _timer.start(); didStartPlaying(); } private function didStartPlaying():void { _isPaused = false; sendEvent(HtmlMediaEvent.PLAY); sendEvent(HtmlMediaEvent.PLAYING); if (!_firedCanPlay) { sendEvent(HtmlMediaEvent.LOADEDDATA); sendEvent(HtmlMediaEvent.CANPLAY); _firedCanPlay = true; } } public function setVolume(volume:Number):void { _volume = volume; _soundTransform.volume = volume; if (_soundChannel != null) { _soundChannel.soundTransform = _soundTransform; } _isMuted = (_volume == 0); sendEvent(HtmlMediaEvent.VOLUMECHANGE); } public function getVolume():Number { if(_isMuted) { return 0; } else { return _volume; } } public function setMuted(muted:Boolean):void { // ignore if already set if ( (muted && _isMuted) || (!muted && !_isMuted)) return; if (muted) { _preMuteVolume = _soundTransform.volume; setVolume(0); } else { setVolume(_preMuteVolume); } _isMuted = muted; } public function unload():void { _sound = null; _isLoaded = false; } private function sendEvent(eventName:String) { // calculate this to mimic HTML5 _bufferedTime = _bytesLoaded / _bytesTotal * _duration; // build JSON var values:String = "duration:" + _duration + ",currentTime:" + _currentTime + ",muted:" + _isMuted + ",paused:" + _isPaused + ",ended:" + _isEnded + ",volume:" + _volume + ",src:\"" + _currentUrl + "\"" + ",bytesTotal:" + _bytesTotal + ",bufferedBytes:" + _bytesLoaded + ",bufferedTime:" + _bufferedTime + ""; _element.sendEvent(eventName, values); } } } \ No newline at end of file
+
+package htmlelements
+{
+ import flash.events.Event;
+ import flash.events.IOErrorEvent;
+ import flash.events.ProgressEvent;
+ import flash.events.TimerEvent;
+ import flash.media.ID3Info;
+ import flash.media.Sound;
+ import flash.media.SoundChannel;
+ import flash.media.SoundLoaderContext;
+ import flash.media.SoundTransform;
+ import flash.net.URLRequest;
+ import flash.utils.Timer;
+
+
+
+ /**
+ * ...
+ * @author DefaultUser (Tools -> Custom Arguments...)
+ */
+ public class AudioElement implements IMediaElement
+ {
+
+ private var _sound:Sound;
+ private var _soundTransform:SoundTransform;
+ private var _soundChannel:SoundChannel;
+ private var _soundLoaderContext:SoundLoaderContext;
+
+ private var _volume:Number = 1;
+ private var _preMuteVolume:Number = 0;
+ private var _isMuted:Boolean = false;
+ private var _isPaused:Boolean = true;
+ private var _isEnded:Boolean = false;
+ private var _isLoaded:Boolean = false;
+ private var _currentTime:Number = 0;
+ private var _duration:Number = 0;
+ private var _bytesLoaded:Number = 0;
+ private var _bytesTotal:Number = 0;
+ private var _bufferedTime:Number = 0;
+ private var _bufferingChanged:Boolean = false;
+
+ private var _currentUrl:String = "";
+ private var _autoplay:Boolean = true;
+ private var _preload:String = "";
+
+ private var _element:FlashMediaElement;
+ private var _timer:Timer;
+ private var _firedCanPlay:Boolean = false;
+
+ public function setSize(width:Number, height:Number):void {
+ // do nothing!
+ }
+
+ public function duration():Number {
+ return _duration;
+ }
+
+ public function currentTime():Number {
+ return _currentTime;
+ }
+
+ public function currentProgress():Number {
+ return Math.round(_bytesLoaded/_bytesTotal*100);
+ }
+
+ public function AudioElement(element:FlashMediaElement, autoplay:Boolean, preload:String, timerRate:Number, startVolume:Number)
+ {
+ _element = element;
+ _autoplay = autoplay;
+ _volume = startVolume;
+ _preload = preload;
+
+ _timer = new Timer(timerRate);
+ _timer.addEventListener(TimerEvent.TIMER, timerEventHandler);
+
+ _soundTransform = new SoundTransform(_volume);
+ _soundLoaderContext = new SoundLoaderContext();
+ }
+
+ // events
+ function progressHandler(e:ProgressEvent):void {
+
+ _bytesLoaded = e.bytesLoaded;
+ _bytesTotal = e.bytesTotal;
+
+ // this happens too much to send every time
+ //sendEvent(HtmlMediaEvent.PROGRESS);
+
+ // so now we just trigger a flag and send with the timer
+ _bufferingChanged = true;
+ }
+
+ function id3Handler(e:Event):void {
+ sendEvent(HtmlMediaEvent.LOADEDMETADATA);
+
+ try {
+ var id3:ID3Info = _sound.id3;
+ var obj = {
+ type:'id3',
+ album:id3.album,
+ artist:id3.artist,
+ comment:id3.comment,
+ genre:id3.genre,
+ songName:id3.songName,
+ track:id3.track,
+ year:id3.year
+ }
+ } catch (err:Error) {}
+
+
+ }
+
+ function timerEventHandler(e:TimerEvent) {
+ _currentTime = _soundChannel.position/1000;
+
+ // calculate duration
+ var duration = Math.round(_sound.length * _sound.bytesTotal/_sound.bytesLoaded/100) / 10;
+
+ // check to see if the estimated duration changed
+ if (_duration != duration && !isNaN(duration)) {
+
+ _duration = duration;
+ sendEvent(HtmlMediaEvent.LOADEDMETADATA);
+ }
+
+ // check for progress
+ if (_bufferingChanged) {
+
+ sendEvent(HtmlMediaEvent.PROGRESS);
+
+ _bufferingChanged = false;
+ }
+
+ // send timeupdate
+ sendEvent(HtmlMediaEvent.TIMEUPDATE);
+
+ // sometimes the ended event doesn't fire, here's a fake one
+ if (_duration > 0 && _currentTime >= _duration-0.2) {
+ handleEnded();
+ }
+ }
+
+ function soundCompleteHandler(e:Event) {
+ handleEnded();
+ }
+
+ function handleEnded():void {
+ _timer.stop();
+ _currentTime = 0;
+ _isEnded = true;
+
+ sendEvent(HtmlMediaEvent.ENDED);
+ }
+
+ //events
+
+
+ // METHODS
+ public function setSrc(url:String):void {
+ _currentUrl = url;
+ _isLoaded = false;
+ }
+
+
+ public function load():void {
+
+ if (_currentUrl == "")
+ return;
+
+ _sound = new Sound();
+ //sound.addEventListener(IOErrorEvent.IO_ERROR,errorHandler);
+ _sound.addEventListener(ProgressEvent.PROGRESS,progressHandler);
+ _sound.addEventListener(Event.ID3,id3Handler);
+ _sound.load(new URLRequest(_currentUrl));
+ _currentTime = 0;
+
+ sendEvent(HtmlMediaEvent.LOADSTART);
+
+ _isLoaded = true;
+
+ sendEvent(HtmlMediaEvent.LOADEDDATA);
+ sendEvent(HtmlMediaEvent.CANPLAY);
+ _firedCanPlay = true;
+
+ if (_playAfterLoading) {
+ _playAfterLoading = false;
+ play();
+ }
+ }
+
+ private var _playAfterLoading:Boolean= false;
+
+ public function play():void {
+
+ if (!_isLoaded) {
+ _playAfterLoading = true;
+ load();
+ return;
+ }
+
+ _timer.stop();
+
+ _soundChannel = _sound.play(_currentTime*1000, 0, _soundTransform);
+ _soundChannel.removeEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
+ _soundChannel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
+
+ _timer.start();
+
+ didStartPlaying();
+ }
+
+ public function pause():void {
+
+ _timer.stop();
+ if (_soundChannel != null) {
+ _currentTime = _soundChannel.position/1000;
+ _soundChannel.stop();
+ }
+
+ _isPaused = true;
+ sendEvent(HtmlMediaEvent.PAUSE);
+ }
+
+
+ public function stop():void {
+ if (_timer != null) {
+ _timer.stop();
+ }
+ if (_soundChannel != null) {
+ _soundChannel.stop();
+ _sound.close();
+ }
+ unload();
+ sendEvent(HtmlMediaEvent.STOP);
+ }
+
+ public function setCurrentTime(pos:Number):void {
+ sendEvent(HtmlMediaEvent.SEEKING);
+ _timer.stop();
+ _currentTime = pos;
+ _soundChannel.stop();
+ _sound.length
+ _soundChannel = _sound.play(_currentTime * 1000, 0, _soundTransform);
+ sendEvent(HtmlMediaEvent.SEEKED);
+
+ _timer.start();
+
+ didStartPlaying();
+ }
+
+ private function didStartPlaying():void {
+ _isPaused = false;
+ sendEvent(HtmlMediaEvent.PLAY);
+ sendEvent(HtmlMediaEvent.PLAYING);
+ if (!_firedCanPlay) {
+ sendEvent(HtmlMediaEvent.LOADEDDATA);
+ sendEvent(HtmlMediaEvent.CANPLAY);
+ _firedCanPlay = true;
+ }
+ }
+
+
+ public function setVolume(volume:Number):void {
+
+ _volume = volume;
+ _soundTransform.volume = volume;
+
+ if (_soundChannel != null) {
+ _soundChannel.soundTransform = _soundTransform;
+ }
+
+ _isMuted = (_volume == 0);
+
+ sendEvent(HtmlMediaEvent.VOLUMECHANGE);
+ }
+
+ public function getVolume():Number {
+ if(_isMuted) {
+ return 0;
+ } else {
+ return _volume;
+ }
+ }
+
+
+ public function setMuted(muted:Boolean):void {
+
+ // ignore if already set
+ if ( (muted && _isMuted) || (!muted && !_isMuted))
+ return;
+
+ if (muted) {
+ _preMuteVolume = _soundTransform.volume;
+ setVolume(0);
+ } else {
+ setVolume(_preMuteVolume);
+ }
+
+ _isMuted = muted;
+ }
+
+ public function unload():void {
+ _sound = null;
+ _isLoaded = false;
+ }
+
+ private function sendEvent(eventName:String) {
+
+ // calculate this to mimic HTML5
+ _bufferedTime = _bytesLoaded / _bytesTotal * _duration;
+
+ // build JSON
+ var values:String = "duration:" + _duration +
+ ",currentTime:" + _currentTime +
+ ",muted:" + _isMuted +
+ ",paused:" + _isPaused +
+ ",ended:" + _isEnded +
+ ",volume:" + _volume +
+ ",src:\"" + _currentUrl + "\"" +
+ ",bytesTotal:" + _bytesTotal +
+ ",bufferedBytes:" + _bytesLoaded +
+ ",bufferedTime:" + _bufferedTime +
+ "";
+
+ _element.sendEvent(eventName, values);
+ }
+
+ }
+
+}
+
diff --git a/files_videoviewer/mediaelement/src/flash/htmlelements/IMediaElement.as b/files_videoviewer/mediaelement/src/flash/htmlelements/IMediaElement.as
index 6adfc7014..d62660795 100755
--- a/files_videoviewer/mediaelement/src/flash/htmlelements/IMediaElement.as
+++ b/files_videoviewer/mediaelement/src/flash/htmlelements/IMediaElement.as
@@ -1 +1,35 @@
- package htmlelements { public interface IMediaElement { function play():void; function pause():void; function load():void; function stop():void; function setSrc(url:String):void; function setSize(width:Number, height:Number):void; function setCurrentTime(pos:Number):void; function setVolume(vol:Number):void; function getVolume():Number; function setMuted(muted:Boolean):void; function duration():Number; function currentTime():Number; function currentProgress():Number; } } \ No newline at end of file
+
+package htmlelements
+{
+
+ public interface IMediaElement {
+
+ function play():void;
+
+ function pause():void;
+
+ function load():void;
+
+ function stop():void;
+
+ function setSrc(url:String):void;
+
+ function setSize(width:Number, height:Number):void;
+
+ function setCurrentTime(pos:Number):void;
+
+ function setVolume(vol:Number):void;
+
+ function getVolume():Number;
+
+ function setMuted(muted:Boolean):void;
+
+ function duration():Number;
+
+ function currentTime():Number;
+
+ function currentProgress():Number;
+
+ }
+
+}
diff --git a/files_videoviewer/mediaelement/src/flash/htmlelements/VideoElement.as b/files_videoviewer/mediaelement/src/flash/htmlelements/VideoElement.as
index e7e4ce21a..7673c4f6c 100755
--- a/files_videoviewer/mediaelement/src/flash/htmlelements/VideoElement.as
+++ b/files_videoviewer/mediaelement/src/flash/htmlelements/VideoElement.as
@@ -1 +1 @@
-package htmlelements { import flash.display.Sprite; import flash.events.*; import flash.net.NetConnection; import flash.net.NetStream; import flash.media.Video; import flash.media.SoundTransform; import flash.utils.Timer; import FlashMediaElement; import HtmlMediaEvent; public class VideoElement extends Sprite implements IMediaElement { private var _currentUrl:String = ""; private var _autoplay:Boolean = true; private var _preload:String = ""; private var _isPreloading:Boolean = false; private var _connection:NetConnection; private var _stream:NetStream; private var _video:Video; private var _element:FlashMediaElement; private var _soundTransform; private var _oldVolume:Number = 1; // event values private var _duration:Number = 0; private var _framerate:Number; private var _isPaused:Boolean = true; private var _isEnded:Boolean = false; private var _volume:Number = 1; private var _isMuted:Boolean = false; private var _bytesLoaded:Number = 0; private var _bytesTotal:Number = 0; private var _bufferedTime:Number = 0; private var _bufferEmpty:Boolean = false; private var _bufferingChanged:Boolean = false; private var _seekOffset:Number = 0; private var _videoWidth:Number = -1; private var _videoHeight:Number = -1; private var _timer:Timer; private var _isRTMP:Boolean = false; private var _streamer:String = ""; private var _isConnected:Boolean = false; private var _playWhenConnected:Boolean = false; private var _hasStartedPlaying:Boolean = false; private var _parentReference:Object; private var _pseudoStreamingEnabled:Boolean = false; private var _pseudoStreamingStartQueryParam:String = "start"; public function setReference(arg:Object):void { _parentReference = arg; } public function setSize(width:Number, height:Number):void { _video.width = width; _video.height = height; } public function setPseudoStreaming(enablePseudoStreaming:Boolean):void { _pseudoStreamingEnabled = enablePseudoStreaming; } public function setPseudoStreamingStartParam(pseudoStreamingStartQueryParam:String):void { _pseudoStreamingStartQueryParam = pseudoStreamingStartQueryParam; } public function get video():Video { return _video; } public function get videoHeight():Number { return _videoHeight; } public function get videoWidth():Number { return _videoWidth; } public function duration():Number { return _duration; } public function currentProgress():Number { if(_stream != null) { return Math.round(_stream.bytesLoaded/_stream.bytesTotal*100); } else { return 0; } } public function currentTime():Number { var currentTime:Number = 0; if (_stream != null) { currentTime = _stream.time; if (_pseudoStreamingEnabled) { currentTime += _seekOffset; } } return currentTime; } // (1) load() // calls _connection.connect(); // waits for NetConnection.Connect.Success // _stream gets created public function VideoElement(element:FlashMediaElement, autoplay:Boolean, preload:String, timerRate:Number, startVolume:Number, streamer:String) { _element = element; _autoplay = autoplay; _volume = startVolume; _preload = preload; _streamer = streamer; _video = new Video(); addChild(_video); _connection = new NetConnection(); _connection.client = { onBWDone: function():void{} }; _connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); _connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); //_connection.connect(null); _timer = new Timer(timerRate); _timer.addEventListener("timer", timerHandler); } private function timerHandler(e:TimerEvent) { _bytesLoaded = _stream.bytesLoaded; _bytesTotal = _stream.bytesTotal; if (!_isPaused) { sendEvent(HtmlMediaEvent.TIMEUPDATE); } //trace("bytes", _bytesLoaded, _bytesTotal); if (_bytesLoaded < _bytesTotal) sendEvent(HtmlMediaEvent.PROGRESS); } // internal events private function netStatusHandler(event:NetStatusEvent):void { trace("netStatus", event.info.code); switch (event.info.code) { case "NetStream.Buffer.Empty": _bufferEmpty = true; _isEnded ? sendEvent(HtmlMediaEvent.ENDED) : null; break; case "NetStream.Buffer.Full": _bytesLoaded = _stream.bytesLoaded; _bytesTotal = _stream.bytesTotal; _bufferEmpty = false; sendEvent(HtmlMediaEvent.PROGRESS); break; case "NetConnection.Connect.Success": connectStream(); break; case "NetStream.Play.StreamNotFound": trace("Unable to locate video"); break; // STREAM case "NetStream.Play.Start": _isPaused = false; sendEvent(HtmlMediaEvent.LOADEDDATA); sendEvent(HtmlMediaEvent.CANPLAY); if (!_isPreloading) { sendEvent(HtmlMediaEvent.PLAY); sendEvent(HtmlMediaEvent.PLAYING); } _timer.start(); break; case "NetStream.Seek.Notify": sendEvent(HtmlMediaEvent.SEEKED); break; case "NetStream.Pause.Notify": _isPaused = true; sendEvent(HtmlMediaEvent.PAUSE); break; case "NetStream.Play.Stop": _isEnded = true; _isPaused = false; _timer.stop(); _bufferEmpty ? sendEvent(HtmlMediaEvent.ENDED) : null; break; } } private function securityErrorHandler(event:SecurityErrorEvent):void { trace("securityErrorHandler: " + event); } private function asyncErrorHandler(event:AsyncErrorEvent):void { // ignore AsyncErrorEvent events. } private function onMetaDataHandler(info:Object):void { // Only set the duration when we first load the video if (_duration == 0) { _duration = info.duration; } _framerate = info.framerate; _videoWidth = info.width; _videoHeight = info.height; // set size? sendEvent(HtmlMediaEvent.LOADEDMETADATA); if (_isPreloading) { _stream.pause(); _isPaused = true; _isPreloading = false; sendEvent(HtmlMediaEvent.PROGRESS); sendEvent(HtmlMediaEvent.TIMEUPDATE); } } // interface members public function setSrc(url:String):void { if (_isConnected && _stream) { // stop and restart _stream.pause(); } _currentUrl = url; _isRTMP = !!_currentUrl.match(/^rtmp(s|t|e|te)?\:\/\//) || _streamer != ""; _isConnected = false; _hasStartedPlaying = false; } public function load():void { // disconnect existing stream and connection if (_isConnected && _stream) { _stream.pause(); _stream.close(); _connection.close(); } _isConnected = false; _isPreloading = false; _isEnded = false; _bufferEmpty = false; // start new connection if (_isRTMP) { var rtmpInfo:Object = parseRTMP(_currentUrl); if (_streamer != "") { rtmpInfo.server = _streamer; rtmpInfo.stream = _currentUrl; } _connection.connect(rtmpInfo.server); } else { _connection.connect(null); } // in a few moments the "NetConnection.Connect.Success" event will fire // and call createConnection which finishes the "load" sequence sendEvent(HtmlMediaEvent.LOADSTART); } private function connectStream():void { trace("connectStream"); _stream = new NetStream(_connection); // explicitly set the sound since it could have come before the connection was made _soundTransform = new SoundTransform(_volume); stream.soundTransform = _soundTransform; // set the buffer to ensure nice playback _stream.bufferTime = 1; _stream.bufferTimeMax = 3; _stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); // same event as connection _stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); var customClient:Object = new Object(); customClient.onMetaData = onMetaDataHandler; _stream.client = customClient; _video.attachNetStream(_stream); // start downloading without playing )based on preload and play() hasn't been called) // I wish flash had a load() command to make this less awkward if (_preload != "none" && !_playWhenConnected) { _isPaused = true; //stream.bufferTime = 20; _stream.play(getCurrentUrl(0), 0, 0); _stream.pause(); _isPreloading = true; //_stream.pause(); // //sendEvent(HtmlMediaEvent.PAUSE); // have to send this because the "playing" event gets sent via event handlers } _isConnected = true; if (_playWhenConnected && !_hasStartedPlaying) { play(); _playWhenConnected = false; } } public function play():void { if (!_hasStartedPlaying && !_isConnected) { _playWhenConnected = true; load(); return; } if (_hasStartedPlaying) { if (_isPaused) { _stream.resume(); _timer.start(); _isPaused = false; sendEvent(HtmlMediaEvent.PLAY); sendEvent(HtmlMediaEvent.PLAYING); } } else { if (_isRTMP) { var rtmpInfo:Object = parseRTMP(_currentUrl); _stream.play(rtmpInfo.stream); } else { _stream.play(getCurrentUrl(0)); } _timer.start(); _isPaused = false; _hasStartedPlaying = true; // don't toss play/playing events here, because we haven't sent a // canplay / loadeddata event yet. that'll be handled in the net // event listener } } public function pause():void { if (_stream == null) return; _stream.pause(); _isPaused = true; if (_bytesLoaded == _bytesTotal) { _timer.stop(); } _isPaused = true; sendEvent(HtmlMediaEvent.PAUSE); } public function stop():void { if (_stream == null) return; _stream.close(); _isPaused = false; _timer.stop(); sendEvent(HtmlMediaEvent.STOP); } public function setCurrentTime(pos:Number):void { if (_stream == null) { return; } // Calculate the position of the buffered video var bufferPosition:Number = _bytesLoaded / _bytesTotal * _duration; if (_pseudoStreamingEnabled) { sendEvent(HtmlMediaEvent.SEEKING); // Normal seek if it is in buffer and this is the first seek if (pos < bufferPosition && _seekOffset == 0) { _stream.seek(pos); } else { // Uses server-side pseudo-streaming to seek _stream.play(getCurrentUrl(pos)); _seekOffset = pos; } } else { sendEvent(HtmlMediaEvent.SEEKING); _stream.seek(pos); } if (!_isEnded) { sendEvent(HtmlMediaEvent.TIMEUPDATE); } } public function setVolume(volume:Number):void { if (_stream != null) { _soundTransform = new SoundTransform(volume); _stream.soundTransform = _soundTransform; } _volume = volume; _isMuted = (_volume == 0); sendEvent(HtmlMediaEvent.VOLUMECHANGE); } public function getVolume():Number { if(_isMuted) { return 0; } else { return _volume; } } public function setMuted(muted:Boolean):void { if (_isMuted == muted) return; if (muted) { _oldVolume = (_stream == null) ? _oldVolume : _stream.soundTransform.volume; setVolume(0); } else { setVolume(_oldVolume); } _isMuted = muted; } private function sendEvent(eventName:String) { // calculate this to mimic HTML5 _bufferedTime = _bytesLoaded / _bytesTotal * _duration; // build JSON var values:String = "duration:" + _duration + ",framerate:" + _framerate + ",currentTime:" + currentTime() + ",muted:" + _isMuted + ",paused:" + _isPaused + ",ended:" + _isEnded + ",volume:" + _volume + ",src:\"" + _currentUrl + "\"" + ",bytesTotal:" + _bytesTotal + ",bufferedBytes:" + _bytesLoaded + ",bufferedTime:" + _bufferedTime + ",videoWidth:" + _videoWidth + ",videoHeight:" + _videoHeight + ""; _element.sendEvent(eventName, values); } private function parseRTMP(url:String) { var match:Array = url.match(/(.*)\/((flv|mp4|mp3):.*)/); var rtmpInfo:Object = { server: null, stream: null }; if (match) { rtmpInfo.server = match[1]; rtmpInfo.stream = match[2]; } else { rtmpInfo.server = url.replace(/\/[^\/]+$/,"/"); rtmpInfo.stream = url.split("/").pop(); } trace("parseRTMP - server: " + rtmpInfo.server + " stream: " + rtmpInfo.stream); return rtmpInfo; } private function getCurrentUrl(pos:Number):String { var url:String = _currentUrl; if (_pseudoStreamingEnabled) { if (url.indexOf('?') > -1) { url = url + '&' + _pseudoStreamingStartQueryParam + '=' + pos; } else { url = url + '?' + _pseudoStreamingStartQueryParam + '=' + pos; } } return url; } } } \ No newline at end of file
+package htmlelements { import flash.display.Sprite; import flash.events.*; import flash.net.NetConnection; import flash.net.NetStream; import flash.media.Video; import flash.media.SoundTransform; import flash.utils.Timer; import FlashMediaElement; import HtmlMediaEvent; public class VideoElement extends Sprite implements IMediaElement { private var _currentUrl:String = ""; private var _autoplay:Boolean = true; private var _preload:String = ""; private var _isPreloading:Boolean = false; private var _connection:NetConnection; private var _stream:NetStream; private var _video:Video; private var _element:FlashMediaElement; private var _soundTransform; private var _oldVolume:Number = 1; // event values private var _duration:Number = 0; private var _framerate:Number; private var _isPaused:Boolean = true; private var _isEnded:Boolean = false; private var _volume:Number = 1; private var _isMuted:Boolean = false; private var _bytesLoaded:Number = 0; private var _bytesTotal:Number = 0; private var _bufferedTime:Number = 0; private var _bufferEmpty:Boolean = false; private var _bufferingChanged:Boolean = false; private var _seekOffset:Number = 0; private var _videoWidth:Number = -1; private var _videoHeight:Number = -1; private var _timer:Timer; private var _isRTMP:Boolean = false; private var _streamer:String = ""; private var _isConnected:Boolean = false; private var _playWhenConnected:Boolean = false; private var _hasStartedPlaying:Boolean = false; private var _parentReference:Object; private var _pseudoStreamingEnabled:Boolean = false; private var _pseudoStreamingStartQueryParam:String = "start"; public function setReference(arg:Object):void { _parentReference = arg; } public function setSize(width:Number, height:Number):void { _video.width = width; _video.height = height; } public function setPseudoStreaming(enablePseudoStreaming:Boolean):void { _pseudoStreamingEnabled = enablePseudoStreaming; } public function setPseudoStreamingStartParam(pseudoStreamingStartQueryParam:String):void { _pseudoStreamingStartQueryParam = pseudoStreamingStartQueryParam; } public function get video():Video { return _video; } public function get videoHeight():Number { return _videoHeight; } public function get videoWidth():Number { return _videoWidth; } public function duration():Number { return _duration; } public function currentProgress():Number { if(_stream != null) { return Math.round(_stream.bytesLoaded/_stream.bytesTotal*100); } else { return 0; } } public function currentTime():Number { var currentTime:Number = 0; if (_stream != null) { currentTime = _stream.time; if (_pseudoStreamingEnabled) { currentTime += _seekOffset; } } return currentTime; } // (1) load() // calls _connection.connect(); // waits for NetConnection.Connect.Success // _stream gets created public function VideoElement(element:FlashMediaElement, autoplay:Boolean, preload:String, timerRate:Number, startVolume:Number, streamer:String) { _element = element; _autoplay = autoplay; _volume = startVolume; _preload = preload; _streamer = streamer; _video = new Video(); addChild(_video); _connection = new NetConnection(); _connection.client = { onBWDone: function():void{} }; _connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); _connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); //_connection.connect(null); _timer = new Timer(timerRate); _timer.addEventListener("timer", timerHandler); } private function timerHandler(e:TimerEvent) { _bytesLoaded = _stream.bytesLoaded; _bytesTotal = _stream.bytesTotal; if (!_isPaused) { sendEvent(HtmlMediaEvent.TIMEUPDATE); } //trace("bytes", _bytesLoaded, _bytesTotal); if (_bytesLoaded < _bytesTotal) sendEvent(HtmlMediaEvent.PROGRESS); } // internal events private function netStatusHandler(event:NetStatusEvent):void { trace("netStatus", event.info.code); switch (event.info.code) { case "NetStream.Buffer.Empty": _bufferEmpty = true; _isEnded ? sendEvent(HtmlMediaEvent.ENDED) : null; break; case "NetStream.Buffer.Full": _bytesLoaded = _stream.bytesLoaded; _bytesTotal = _stream.bytesTotal; _bufferEmpty = false; sendEvent(HtmlMediaEvent.PROGRESS); break; case "NetConnection.Connect.Success": connectStream(); break; case "NetStream.Play.StreamNotFound": trace("Unable to locate video"); break; // STREAM case "NetStream.Play.Start": _isPaused = false; sendEvent(HtmlMediaEvent.LOADEDDATA); sendEvent(HtmlMediaEvent.CANPLAY); if (!_isPreloading) { sendEvent(HtmlMediaEvent.PLAY); sendEvent(HtmlMediaEvent.PLAYING); } _timer.start(); break; case "NetStream.Seek.Notify": sendEvent(HtmlMediaEvent.SEEKED); break; case "NetStream.Pause.Notify": _isPaused = true; sendEvent(HtmlMediaEvent.PAUSE); break; case "NetStream.Play.Stop": _isEnded = true; _isPaused = false; _timer.stop(); _bufferEmpty ? sendEvent(HtmlMediaEvent.ENDED) : null; break; } } private function securityErrorHandler(event:SecurityErrorEvent):void { trace("securityErrorHandler: " + event); } private function asyncErrorHandler(event:AsyncErrorEvent):void { // ignore AsyncErrorEvent events. } private function onMetaDataHandler(info:Object):void { // Only set the duration when we first load the video if (_duration == 0) { _duration = info.duration; } _framerate = info.framerate; _videoWidth = info.width; _videoHeight = info.height; // set size? sendEvent(HtmlMediaEvent.LOADEDMETADATA); if (_isPreloading) { _stream.pause(); _isPaused = true; _isPreloading = false; sendEvent(HtmlMediaEvent.PROGRESS); sendEvent(HtmlMediaEvent.TIMEUPDATE); } } // interface members public function setSrc(url:String):void { if (_isConnected && _stream) { // stop and restart _stream.pause(); } _currentUrl = url; _isRTMP = !!_currentUrl.match(/^rtmp(s|t|e|te)?\:\/\//) || _streamer != ""; _isConnected = false; _hasStartedPlaying = false; } public function load():void { // disconnect existing stream and connection if (_isConnected && _stream) { _stream.pause(); _stream.close(); _connection.close(); } _isConnected = false; _isPreloading = false; _isEnded = false; _bufferEmpty = false; // start new connection if (_isRTMP) { var rtmpInfo:Object = parseRTMP(_currentUrl); if (_streamer != "") { rtmpInfo.server = _streamer; rtmpInfo.stream = _currentUrl; } _connection.connect(rtmpInfo.server); } else { _connection.connect(null); } // in a few moments the "NetConnection.Connect.Success" event will fire // and call createConnection which finishes the "load" sequence sendEvent(HtmlMediaEvent.LOADSTART); } private function connectStream():void { trace("connectStream"); _stream = new NetStream(_connection); // explicitly set the sound since it could have come before the connection was made _soundTransform = new SoundTransform(_volume); _stream.soundTransform = _soundTransform; // set the buffer to ensure nice playback _stream.bufferTime = 1; _stream.bufferTimeMax = 3; _stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); // same event as connection _stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); var customClient:Object = new Object(); customClient.onMetaData = onMetaDataHandler; _stream.client = customClient; _video.attachNetStream(_stream); // start downloading without playing )based on preload and play() hasn't been called) // I wish flash had a load() command to make this less awkward if (_preload != "none" && !_playWhenConnected) { _isPaused = true; //stream.bufferTime = 20; _stream.play(getCurrentUrl(0), 0, 0); _stream.pause(); _isPreloading = true; //_stream.pause(); // //sendEvent(HtmlMediaEvent.PAUSE); // have to send this because the "playing" event gets sent via event handlers } _isConnected = true; if (_playWhenConnected && !_hasStartedPlaying) { play(); _playWhenConnected = false; } } public function play():void { if (!_hasStartedPlaying && !_isConnected) { _playWhenConnected = true; load(); return; } if (_hasStartedPlaying) { if (_isPaused) { _stream.resume(); _timer.start(); _isPaused = false; sendEvent(HtmlMediaEvent.PLAY); sendEvent(HtmlMediaEvent.PLAYING); } } else { if (_isRTMP) { var rtmpInfo:Object = parseRTMP(_currentUrl); _stream.play(rtmpInfo.stream); } else { _stream.play(getCurrentUrl(0)); } _timer.start(); _isPaused = false; _hasStartedPlaying = true; // don't toss play/playing events here, because we haven't sent a // canplay / loadeddata event yet. that'll be handled in the net // event listener } } public function pause():void { if (_stream == null) return; _stream.pause(); _isPaused = true; if (_bytesLoaded == _bytesTotal) { _timer.stop(); } _isPaused = true; sendEvent(HtmlMediaEvent.PAUSE); } public function stop():void { if (_stream == null) return; _stream.close(); _isPaused = false; _timer.stop(); sendEvent(HtmlMediaEvent.STOP); } public function setCurrentTime(pos:Number):void { if (_stream == null) { return; } // Calculate the position of the buffered video var bufferPosition:Number = _bytesLoaded / _bytesTotal * _duration; if (_pseudoStreamingEnabled) { sendEvent(HtmlMediaEvent.SEEKING); // Normal seek if it is in buffer and this is the first seek if (pos < bufferPosition && _seekOffset == 0) { _stream.seek(pos); } else { // Uses server-side pseudo-streaming to seek _stream.play(getCurrentUrl(pos)); _seekOffset = pos; } } else { sendEvent(HtmlMediaEvent.SEEKING); _stream.seek(pos); } if (!_isEnded) { sendEvent(HtmlMediaEvent.TIMEUPDATE); } } public function setVolume(volume:Number):void { if (_stream != null) { _soundTransform = new SoundTransform(volume); _stream.soundTransform = _soundTransform; } _volume = volume; _isMuted = (_volume == 0); sendEvent(HtmlMediaEvent.VOLUMECHANGE); } public function getVolume():Number { if(_isMuted) { return 0; } else { return _volume; } } public function setMuted(muted:Boolean):void { if (_isMuted == muted) return; if (muted) { _oldVolume = (_stream == null) ? _oldVolume : _stream.soundTransform.volume; setVolume(0); } else { setVolume(_oldVolume); } _isMuted = muted; } private function sendEvent(eventName:String) { // calculate this to mimic HTML5 _bufferedTime = _bytesLoaded / _bytesTotal * _duration; // build JSON var values:String = "duration:" + _duration + ",framerate:" + _framerate + ",currentTime:" + currentTime() + ",muted:" + _isMuted + ",paused:" + _isPaused + ",ended:" + _isEnded + ",volume:" + _volume + ",src:\"" + _currentUrl + "\"" + ",bytesTotal:" + _bytesTotal + ",bufferedBytes:" + _bytesLoaded + ",bufferedTime:" + _bufferedTime + ",videoWidth:" + _videoWidth + ",videoHeight:" + _videoHeight + ""; _element.sendEvent(eventName, values); } private function parseRTMP(url:String) { var match:Array = url.match(/(.*)\/((flv|mp4|mp3):.*)/); var rtmpInfo:Object = { server: null, stream: null }; if (match) { rtmpInfo.server = match[1]; rtmpInfo.stream = match[2]; } else { rtmpInfo.server = url.replace(/\/[^\/]+$/,"/"); rtmpInfo.stream = url.split("/").pop(); } trace("parseRTMP - server: " + rtmpInfo.server + " stream: " + rtmpInfo.stream); return rtmpInfo; } private function getCurrentUrl(pos:Number):String { var url:String = _currentUrl; if (_pseudoStreamingEnabled) { if (url.indexOf('?') > -1) { url = url + '&' + _pseudoStreamingStartQueryParam + '=' + pos; } else { url = url + '?' + _pseudoStreamingStartQueryParam + '=' + pos; } } return url; } } } \ No newline at end of file
diff --git a/files_videoviewer/mediaelement/src/flash/htmlelements/YouTubeElement.as b/files_videoviewer/mediaelement/src/flash/htmlelements/YouTubeElement.as
index f77343da7..692a42621 100755
--- a/files_videoviewer/mediaelement/src/flash/htmlelements/YouTubeElement.as
+++ b/files_videoviewer/mediaelement/src/flash/htmlelements/YouTubeElement.as
@@ -400,4 +400,4 @@ package htmlelements
_element.sendEvent(eventName, values);
}
}
-} \ No newline at end of file
+}
diff --git a/files_videoviewer/mediaelement/src/js/me-header.js b/files_videoviewer/mediaelement/src/js/me-header.js
index 444d26682..6d0fcb3dc 100755
--- a/files_videoviewer/mediaelement/src/js/me-header.js
+++ b/files_videoviewer/mediaelement/src/js/me-header.js
@@ -7,7 +7,7 @@
* 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-2012, John Dyer (http://j.hn)
+* Copyright 2010-2013, John Dyer (http://j.hn)
* License: MIT
*
*/ \ No newline at end of file
diff --git a/files_videoviewer/mediaelement/src/js/me-namespace.js b/files_videoviewer/mediaelement/src/js/me-namespace.js
index c9fc1d785..d9880c8d9 100755
--- a/files_videoviewer/mediaelement/src/js/me-namespace.js
+++ b/files_videoviewer/mediaelement/src/js/me-namespace.js
@@ -2,7 +2,7 @@
var mejs = mejs || {};
// version number
-mejs.version = '2.11.1';
+mejs.version = '2.11.3';
// player number (for missing, same id attr)
mejs.meIndex = 0;
diff --git a/files_videoviewer/mediaelement/src/js/me-shim.js b/files_videoviewer/mediaelement/src/js/me-shim.js
index 63992b9bc..d1a5e6d90 100755
--- a/files_videoviewer/mediaelement/src/js/me-shim.js
+++ b/files_videoviewer/mediaelement/src/js/me-shim.js
@@ -675,7 +675,7 @@ mejs.YouTubeApi = {
loadIframeApi: function() {
if (!this.isIframeStarted) {
var tag = document.createElement('script');
- tag.src = "http://www.youtube.com/player_api";
+ tag.src = "//www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
this.isIframeStarted = true;
@@ -793,7 +793,7 @@ mejs.YouTubeApi = {
*/
var specialIEContainer,
- youtubeUrl = 'http://www.youtube.com/apiplayer?enablejsapi=1&amp;playerapiid=' + settings.pluginId + '&amp;version=3&amp;autoplay=0&amp;controls=0&amp;modestbranding=1&loop=0';
+ youtubeUrl = '//www.youtube.com/apiplayer?enablejsapi=1&amp;playerapiid=' + settings.pluginId + '&amp;version=3&amp;autoplay=0&amp;controls=0&amp;modestbranding=1&loop=0';
if (mejs.MediaFeatures.isIE) {
diff --git a/files_videoviewer/mediaelement/src/js/me-utility.js b/files_videoviewer/mediaelement/src/js/me-utility.js
index 00c1a9381..305cf3e55 100755
--- a/files_videoviewer/mediaelement/src/js/me-utility.js
+++ b/files_videoviewer/mediaelement/src/js/me-utility.js
@@ -17,29 +17,47 @@ mejs.Utility = {
var
i = 0,
j,
- path = '',
- name = '',
- pos,
- script,
+ codePath = '',
+ testname = '',
+ slashPos,
+ filenamePos,
+ scriptUrl,
+ scriptPath,
+ scriptFilename,
scripts = document.getElementsByTagName('script'),
il = scripts.length,
jl = scriptNames.length;
-
+
+ // go through all <script> tags
for (; i < il; i++) {
- script = scripts[i].src;
+ scriptUrl = scripts[i].src;
+ slashPos = scriptUrl.lastIndexOf('/');
+ if (slashPos > -1) {
+ scriptFilename = scriptUrl.substring(slashPos + 1);
+ scriptPath = scriptUrl.substring(0, slashPos + 1);
+ } else {
+ scriptFilename = scriptUrl;
+ scriptPath = '';
+ }
+
+ // see if any <script> tags have a file name that matches the
for (j = 0; j < jl; j++) {
- name = scriptNames[j];
- pos = script.indexOf(name);
- if (pos > -1 && pos == script.length - name.length) {
- path = script.substring(0, pos);
+ testname = scriptNames[j];
+ filenamePos = scriptFilename.indexOf(testname);
+ if (filenamePos > -1) {
+ codePath = scriptPath;
break;
}
}
- if (path !== '') {
+
+ // if we found a path, then break and return it
+ if (codePath !== '') {
break;
}
}
- return path;
+
+ // send the best path back
+ return codePath;
},
secondsToTimeCode: function(time, forceHours, showFrameCount, fps) {
//add framecount