From: stevenaw Date: Wed, 16 Mar 2011 12:46:23 +0000 (-0400) Subject: [#280] Cleanup, tests done X-Git-Tag: v0.4~6^2~5 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6d00162be198a884ffb13bf900f962b171a26d76;p=popcorn-js.git [#280] Cleanup, tests done --- diff --git a/players/vimeo/froogaloop.min.js b/players/vimeo/froogaloop.min.js deleted file mode 100644 index f911b71..0000000 --- a/players/vimeo/froogaloop.min.js +++ /dev/null @@ -1,5 +0,0 @@ -var Froogaloop=function(){var e={hasWindowEvent:false,PLAYER_DOMAIN:"",eventCallbacks:{},iframe_pattern:/player\.(([a-zA-Z0-9_\.]+)\.)?vimeo(ws)?\.com\/video\/([0-9]+)/i},j=function(b){b||(b=document.getElementsByTagName("iframe"));for(var a,c=0,f=b.length,g;c0?a.apply(null,b):a.call()},d={r20:/%20/g,isArray:function(b){return Object.prototype.toString.call(b)=== -"[object Array]"},isFunction:function(b){return Object.prototype.toString.call(b)==="[object Function]"},unserialize:function(b){if(!b)return false;var a={};b=b.split("&");for(var c,f,g=0;g-1)f=d.unserialize(f);a[c]=f}return a},s:false,serialize:function(b){d.s=[];for(var a in b)d.buildParams(a,b[a]);return d.s.join("&").replace(d.r20,"+")},buildParams:function(b,a){var c=0;if(d.isArray(a)){for(;cFootnote Area
-
+


diff --git a/players/vimeo/popcorn.vimeo.js b/players/vimeo/popcorn.vimeo.js index 3fa052e..362e8ac 100644 --- a/players/vimeo/popcorn.vimeo.js +++ b/players/vimeo/popcorn.vimeo.js @@ -2,38 +2,43 @@ ( function( Popcorn ) { /** * Vimeo wrapper for Popcorn. - * This player adds enables Popcorn.js to handle Vimeo videos. It does so by masking an embedded Vimeo video iframe + * This player adds enables Popcorn.js to handle Vimeo videos. It does so by masking an embedded Vimeo video Flash object * as a video and implementing the HTML5 Media Element interface. * - * To use this plug-in, include the Vimeo JavaScript API Froogaloop in the parent HTML page as well as the embedded Vimeo iframe: + * You can specify the video in four ways: + * 1. Use the embed code path supplied by Vimeo as a div's src, and pass the div id into a new Popcorn.vimeo object * - * - * - * You can specify the video in three ways: - * 1. Use the embed code supplied by Vimeo, and pass the iframe id into a new Popcorn.VimeoEngine object + *
+ * + & + * 2. Pass the div id and the embed code path supplied by Vimeo into a new Popcorn.vimeo object * - * + *
* * - * 2. Use an empty iframe and give both the iframe id and the web url when creating a new Popcorn.VimeoEngine + * 3. Use a web url as a div's src, and pass the div id into a new Popcorn.vimeo object * - * + *
* * - * 3. Set the iframe's src attribute to the vimeo video's web url, and pass the id when creating a new Popcorn.VimeoEngine + * 4. Pass the div id and the web url into a new Popcorn.vimeo object * - * + *
* * @@ -71,19 +76,18 @@ * Due to Vimeo's API, some attributes are be supported while others are not. * Supported media attributes: * autoplay ( via Popcorn ) - * currentTime ( get only, set by calling setCurrentTime() ) + * currentTime * duration ( get only ) * ended ( get only ) * initialTime ( get only, always 0 ) * loop ( get only, set by calling setLoop() ) - * muted ( get only, set by calling setVolume(0) ) + * muted ( get only ) * paused ( get only ) * readyState ( get only ) - * src ( get only ) - * volume ( get only, set by calling setVolume() ) + * volume * * load() function - * mute() function + * mute() function ( toggles on/off ) * * Unsupported media attributes: * buffered @@ -94,18 +98,21 @@ * preload * seekable * seeking + * src * startOffsetTime */ + // Trackers var timeupdateInterval = 33, timeCheckInterval = 0.75, abs = Math.abs, registry = {}; // base object for DOM-related behaviour like events - var LikeADOM = function ( owner ) { + var EventManager = function ( owner ) { var evts = {}; - var makeHandler = function( evtName ) { + + function makeHandler( evtName ) { if ( !evts[evtName] ) { evts[evtName] = []; @@ -204,6 +211,10 @@ // Expect id to be a valid 32/64-bit unsigned integer // Returns string, empty string if could not match function extractIdFromUri( uri ) { + if ( !uri ) { + return; + } + var matches = uri.match( rPlayerUri ); return matches ? matches[0].substr(30) : ""; }; @@ -213,6 +224,10 @@ // Expect id to be a valid 32/64-bit unsigned integer // Returns string, empty string if could not match function extractIdFromUrl( url ) { + if ( !url ) { + return; + } + var matches = url.match( rWebUrl ); return matches ? matches[0].substr(10) : ""; }; @@ -228,11 +243,13 @@ container = document.getElementById( containerId ), width, height, - autoplay; + // For flash embedding + params, + flashvars, + attributes = {}; this.addEventFn; this.evtHolder; - this.autoplay; this.paused = true; this.duration = Number.MAX_VALUE; this.ended = 0; @@ -245,9 +262,8 @@ this.previousCurrentTime = this.currentTime; this.previousVolume = this.volume; - this.evtHolder = new LikeADOM( this ); + this.evtHolder = new EventManager( this ); - autoplay = !!container.autoplay ? 1 : 0; width = container.getAttribute( "width" ) || "504"; height = container.getAttribute( "height" ) || "340"; @@ -258,7 +274,7 @@ } if ( !vidId ){ - vidId = extractIdFromUrl( this.swfObj.src ) || extractIdFromUri( this.swfObj.src ); + vidId = extractIdFromUrl( container.getAttribute("src") ) || extractIdFromUri( container.getAttribute("src") ); } if ( !vidId ) { @@ -267,7 +283,7 @@ registry[ containerId ] = this; - var flashvars = { + flashvars = { clip_id: vidId, show_portrait: 1, show_byline: 1, @@ -276,11 +292,10 @@ js_onLoad: 'Popcorn.vimeo.onLoad', // moogaloop will call this JS function when it's done loading (optional) js_swf_id: containerId // this will be passed into all event methods so you can keep track of multiple moogaloops (optional) }; - var params = { + params = { allowscriptaccess: 'always', allowfullscreen: 'true' }; - var attributes = {}; if( hasAPILoaded ) { swfobject.embedSWF("http://vimeo.com/moogaloop.swf", containerId, width, height, "9.0.0","expressInstall.swf", flashvars, params, attributes); @@ -292,6 +307,7 @@ var evts = {}, retFn; + // The actual (temporary) event listener function retFn = function( evt, fn ) { evt = evt.toLowerCase(); @@ -302,6 +318,7 @@ evts[evt].push( fn ); } + // Used to transfer events from the old to the new once the API loader (either SWFObject or Froogaloop) has loaded retFn.transferToHandler = function() { // No need to keep caching events, now we can connect them to the API directly! this.addEventListener = Popcorn.vimeo.prototype.addEventListener; @@ -368,6 +385,7 @@ that.evtHolder.dispatchEvent( "readystatechange" ); } + // Check if fully loaded if ( data.percent === 100 ) { that.readyState = 4; that.evtHolder.dispatchEvent( "readystatechange" ); @@ -439,10 +457,12 @@ this.evtHolder.dispatchEvent( "play" ); this.swfObj.api_play(); }, - // Pauses the video + // Pause the video pause: function() { this.swfObj.api_pause(); }, + // Toggle video muting + // Unmuting will leave it at the old value mute: function() { if ( !this.muted() ) { this.oldVol = this.volume; @@ -505,7 +525,6 @@ this.evtHolder.addEventListener( evt, fn, false ); // Link manual event structure with Vimeo's if not already - // Do not link for 'timeupdate' if( playerEvt && this.evtHolder.getEventListeners( evt ).length === 1 ) { // Setup global functions on Popcorn.vimeo to sync player events to an internal collection // Some events expect 2 args, some only one (the player id) diff --git a/players/vimeo/popcorn.vimeo.unit.html b/players/vimeo/popcorn.vimeo.unit.html index 7be1d61..6b4bddb 100644 --- a/players/vimeo/popcorn.vimeo.unit.html +++ b/players/vimeo/popcorn.vimeo.unit.html @@ -23,6 +23,6 @@
    - +
    diff --git a/players/vimeo/swfobject.js b/players/vimeo/swfobject.js new file mode 100644 index 0000000..8eafe9d --- /dev/null +++ b/players/vimeo/swfobject.js @@ -0,0 +1,4 @@ +/* SWFObject v2.2 + is released under the MIT License +*/ +var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y0){for(var af=0;af0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad'}}aa.outerHTML='"+af+"";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab