vendor/assets/javascripts/webshims/minified/shims/mediaelement-yt.js in webshims-rails-0.4.4 vs vendor/assets/javascripts/webshims/minified/shims/mediaelement-yt.js in webshims-rails-0.4.5
- old
+ new
@@ -1,14 +2 @@
-jQuery.webshims.register("mediaelement-yt",function(d,e,i,r,m){var n=e.mediaelement,p=jQuery.Deferred();i.onYouTubePlayerAPIReady=function(){p.resolve()};if(i.YT&&YT.Player)i.onYouTubePlayerAPIReady();var i={paused:!0,ended:!1,currentSrc:"",duration:i.NaN,readyState:0,networkState:0,videoHeight:0,videoWidth:0,error:null,buffered:{start:function(b){if(b)e.error("buffered index size error");else return 0},end:function(b){if(b)e.error("buffered index size error");else return 0},length:0}},v=Object.keys(i),
-s={currentTime:0,volume:1,muted:!1};Object.keys(s);var w=d.extend({isActive:"html5",activating:"html5",wasSwfReady:!1,_metadata:!1,_callMeta:!1,currentTime:0,_buffered:0,_ppFlag:m},i,s),k=function(b,c){c=d.Event(c);c.preventDefault();d.event.trigger(c,m,b)},x=function(){var b="_buffered,_metadata,_ppFlag,currentSrc,currentTime,duration,ended,networkState,paused,videoHeight,videoWidth,_callMeta".split(","),c=b.length;return function(a){if(a){var d=c,h=a.networkState;for(a.readyState=0;--d;)delete a[b[d]];
-a.buffered.length=0;clearInterval(a._timeInterval);h&&k(a._elem,"emptied")}}}(),t=function(b){var c=b._elem;b.shadowElem.css({width:c.style.width||d(c).width(),height:c.style.height||d(c).height()})},j=function(b){return(b=e.data(b,"mediaelement"))&&"third"==b.isActive?b:null},y=function(b){var c,b=b.split("?");-1!=b[0].indexOf("youtube.com/watch")&&b[1]?(b=b[1].split("&"),d.each(b,function(a,d){d=d.split("=");if("v"==d[0])return b=d[1],c=!0,!1})):-1!=b[0].indexOf("youtube.com/v/")&&(b=b[0].split("/"),
-d.each(b,function(a,d){if(c)return b=d,!1;"v"==d&&(c=!0)}));c||e.warn("no youtube id found: "+b);return b},u=function(b){b&&(b._ppFlag===m&&d.prop(b._elem,"autoplay")||!b.paused)&&setTimeout(function(){if("third"==b.isActive&&(b._ppFlag===m||!b.paused))try{d(b._elem).play()}catch(c){}},1)},q=d.noop;(function(){var b={play:1,playing:1},c="play,pause,playing,canplay,progress,waiting,ended,loadedmetadata,durationchange,emptied".split(","),a=c.map(function(a){return a+".webshimspolyfill"}).join(" "),
-g=function(a){var c=e.data(a.target,"mediaelement");c&&(a.originalEvent&&a.originalEvent.type===a.type)==("third"==c.activating)&&(a.stopImmediatePropagation(),b[a.type]&&c.isActive!=c.activating&&d(a.target).pause())};q=function(b){d(b).off(a).on(a,g);c.forEach(function(a){e.moveToFirstEvent(b,a)})};q(r)})();d(r).on("emptied",function(b){b=j(b.target);u(b)});n.setActive=function(b,c,a){a||(a=e.data(b,"mediaelement"));if(a&&a.isActive!=c){"html5"!=c&&"third"!=c&&e.warn("wrong type for mediaelement activating: "+
-c);var g=e.data(b,"shadowData");a.activating=c;d(b).pause();a.isActive=c;"third"==c?(g.shadowElement=g.shadowFocusElement=a.shadowElem[0],d(b).addClass("yt-api-active nonnative-api-active").hide().getShadowElement().show()):(clearInterval(a._timeInterval),d(b).removeClass("yt-api-active nonnative-api-active").show().getShadowElement().hide(),g.shadowElement=g.shadowFocusElement=!1);d(b).trigger("mediaelementapichange")}};var o=function(b,c){c._ppFlag=!0;if("playing"==b){o("play",c);if(3>c.readyState)c.readyState=
-3,k(c._elem,"canplay");d(c._elem).trigger("playing")}if("play"==b&&c.paused)c.paused=!1,k(c._elem,"play");else if("pause"==b&&!c.paused)c.paused=!0,k(c._elem,"pause")},z=function(b,c,a,e){p.done(function(){var h=function(){var c,f;if(a._metadata&&a._ytAPI.getVideoLoadedFraction){f=a._ytAPI.getVideoLoadedFraction();c=f*a.duration;if(a._buffered!==c)a._buffered=c,a.buffered.length=1,d(b).trigger("progress");if(0.99<f)a.networkState=1;if(4>a.readyState&&a.currentTime&&(9<a._buffered-a.currentTime||0.9<
-f))a.readyState=4,k(a._elem,"canplaythrough")}},f=function(){if("third"==a.isActive&&a._ytAPI&&a._ytAPI.getVolume){var c=a._ytAPI.getVolume()/100,f=a._ytAPI.isMuted(),l;if(c!=a.volume)a.volume=c,l=!0;if(f!=a.muted)a.muted=f,l=!0;if(a._ytAPI&&a._ytAPI.getCurrentTime){c=a._ytAPI.getCurrentTime();if(a.currentTime!=c)a.currentTime=c,d(b).trigger("timeupdate");h()}h();l&&d(b).trigger("volumechange")}},l=function(){clearInterval(a._timeInterval);a._timeInterval=setInterval(function(){var c=a._ytAPI.getCurrentTime();
-if(a.currentTime!=c)a.currentTime=c,d(b).trigger("timeupdate")},350)};a._ytAPI=new YT.Player(c,{height:"100%",width:"100%",playerVars:{allowfullscreen:!0,fs:1,rel:0,showinfo:0,autohide:1,controls:d.prop(b,"controls")?1:0},videoId:e,events:{onReady:function(){u(a);setTimeout(f,9);setInterval(f,5E3)},onStateChange:function(c){if(c.target.getDuration){var e;if(!a._metadata){var g=c.target.getDuration();if(g){a._metadata=!0;a.duration=g;if(1>a.readyState)a.readyState=1;if(1>a.networkState)a.networkState=
-2;e=!0}}e&&d(b).trigger("durationchange").trigger("loadedmetadata");setTimeout(f,9);if(1==c.data)o("playing",a),l();else if(2==c.data)clearInterval(a._timeInterval),o("pause",a);else if(3==c.data){if(2<a.readyState)a.readyState=2;a.networkState=2;d(b).trigger("waiting")}else if(0===c.data){if(4<a.readyState)a.readyState=4;a.networkState=1;clearInterval(a._timeInterval);d(b).trigger("ended")}}}}});d(b).on("updateytdata",f)})};n.createSWF=function(b,c,a){a||(a=e.data(b,"mediaelement"));var g=y(c.src);
-if(a)n.setActive(b,"third",a),x(a),a.currentSrc=c.srcProp,p.done(function(){a._ytAPI.loadVideoById&&a._ytAPI.loadVideoById(g)});else{d.prop(b,"controls");var h="yt-"+e.getID(b),f=d('<div class="polyfill-video polyfill-mediaelement" id="wrapper-'+h+'"><div id="'+h+'"></div>').css({position:"relative",overflow:"hidden"}),a=e.data(b,"mediaelement",e.objectCreate(w,{shadowElem:{value:f},_elem:{value:b},currentSrc:{value:c.srcProp},buffered:{value:{start:function(b){if(b>=a.buffered.length)e.error("buffered index size error");
-else return 0},end:function(b){if(b>=a.buffered.length)e.error("buffered index size error");else return a._buffered},length:0}}}));t(a);f.insertBefore(b);e.addShadowDom(b,f);n.setActive(b,"third",a);q(b);z(b,h,a,g);d(b).on("updatemediaelementdimensions updateshadowdom",function(){t(a)})}};(function(){var b=function(a){clearTimeout(a.updateDataTimer);a.updateDataTimer=setTimeout(function(){d(a._elem).triggerHandler("updateytdata")},9)},c={},a,g=function(b){c[b]={get:function(){var c=j(this);return c?
-c[b]:a[b].prop._supget.apply(this)},writeable:!1}},h=function(a,b){g(a);delete c[a].writeable;c[a].set=b};v.forEach(g);h("currentTime",function(c){var d=j(this);if(d)c*=1,!isNaN(c)&&d._ytAPI&&d._ytAPI.seekTo&&(d._ytAPI.seekTo(c),b(d));else return a.currentTime.prop._supset.apply(this,arguments)});h("muted",function(c){var d=j(this);if(d)d._ytAPI&&d._ytAPI.mute&&(d._ytAPI[c?"mute":"unMute"](),b(d));else return a.muted.prop._supset.apply(this,arguments)});h("volume",function(c){var d=j(this);if(d)c*=
-100,!isNaN(c)&&d._ytAPI&&d._ytAPI.setVolume&&((0>c||100<c)&&e.error("volume greater or less than allowed "+c/100),d._ytAPI.setVolume(c),b(d));else return a.volume.prop._supset.apply(this,arguments)});d.each(["play","pause"],function(b,d){var e=d+"Video";c[d]={value:function(){var b=j(this);if(b)b._ytAPI&&b._ytAPI[e]&&(b._ytAPI[e](),o(d,b));else return a[d].prop._supvalue.apply(this,arguments)}}});a=e.defineNodeNameProperties("video",c,"prop")})()});
+jQuery.webshims.register("mediaelement-yt",function(e,t,n,r,i,s){"use strict";var o=t.mediaelement,u=jQuery.Deferred();n.onYouTubePlayerAPIReady=function(){u.resolve()},n.YT&&YT.Player&&n.onYouTubePlayerAPIReady();var a={paused:!0,ended:!1,currentSrc:"",duration:n.NaN,readyState:0,networkState:0,videoHeight:0,videoWidth:0,error:null,buffered:{start:function(e){if(e){t.error("buffered index size error");return}return 0},end:function(e){if(e){t.error("buffered index size error");return}return 0},length:0}},f=Object.keys(a),l={currentTime:0,volume:1,muted:!1},c=Object.keys(l),h=e.extend({isActive:"html5",activating:"html5",wasSwfReady:!1,_metadata:!1,_callMeta:!1,currentTime:0,_buffered:0,_ppFlag:i},a,l),p=function(t,n){n=e.Event(n),n.preventDefault(),e.event.trigger(n,i,t)},d=function(){var e=["_buffered","_metadata","_ppFlag","currentSrc","currentTime","duration","ended","networkState","paused","videoHeight","videoWidth","_callMeta"],t=e.length;return function(n){if(!n)return;var r=t,i=n.networkState;n.readyState=0;while(--r)delete n[e[r]];n.buffered.length=0,clearInterval(n._timeInterval),i&&p(n._elem,"emptied")}}(),v=function(t){var n=t._elem,r=t.shadowElem;r.css({width:n.style.width||e(n).width(),height:n.style.height||e(n).height()})},m=function(e){try{e.nodeName}catch(n){return null}var r=t.data(e,"mediaelement");return r&&r.isActive=="third"?r:null},g=function(n){var r;return n=n.split("?"),n[0].indexOf("youtube.com/watch")!=-1&&n[1]?(n=n[1].split("&"),e.each(n,function(e,t){t=t.split("=");if(t[0]=="v")return n=t[1],r=!0,!1})):n[0].indexOf("youtube.com/v/")!=-1&&(n=n[0].split("/"),e.each(n,function(e,t){if(r)return n=t,!1;t=="v"&&(r=!0)})),r||t.warn("no youtube id found: "+n),n},y=function(t){if(!t)return;(t._ppFlag===i&&e.prop(t._elem,"autoplay")||!t.paused)&&setTimeout(function(){if(t.isActive=="third"&&(t._ppFlag===i||!t.paused))try{e(t._elem).play()}catch(n){}},1)},b=e.noop;(function(){var n={play:1,playing:1},i=["play","pause","playing","canplay","progress","waiting","ended","loadedmetadata","durationchange","emptied"],s=i.map(function(e){return e+".webshimspolyfill"}).join(" "),o=function(r){var i=t.data(r.target,"mediaelement");if(!i)return;var s=r.originalEvent&&r.originalEvent.type===r.type;s==(i.activating=="third")&&(r.stopImmediatePropagation(),n[r.type]&&i.isActive!=i.activating&&e(r.target).pause())};b=function(n){e(n).off(s).on(s,o),i.forEach(function(e){t.moveToFirstEvent(n,e)})},b(r)})(),e(r).on("emptied",function(e){var t=m(e.target);y(t)}),o.setActive=function(n,r,i){i||(i=t.data(n,"mediaelement"));if(!i||i.isActive==r)return;r!="html5"&&r!="third"&&t.warn("wrong type for mediaelement activating: "+r);var s=t.data(n,"shadowData");i.activating=r,e(n).pause(),i.isActive=r,r=="third"?(s.shadowElement=s.shadowFocusElement=i.shadowElem[0],e(n).addClass("yt-api-active nonnative-api-active").hide().getShadowElement().show()):(clearInterval(i._timeInterval),e(n).removeClass("yt-api-active nonnative-api-active").show().getShadowElement().hide(),s.shadowElement=s.shadowFocusElement=!1),e(n).trigger("mediaelementapichange")};var w=function(t,n){n._ppFlag=!0,t=="playing"&&(w("play",n),n.readyState<3&&(n.readyState=3,p(n._elem,"canplay")),e(n._elem).trigger("playing")),t=="play"&&n.paused?(n.paused=!1,p(n._elem,"play")):t=="pause"&&!n.paused&&(n.paused=!0,p(n._elem,"pause"))},E=function(t,n,r,i){u.done(function(){var s=function(){var n,i;r._metadata&&r._ytAPI.getVideoLoadedFraction&&(i=r._ytAPI.getVideoLoadedFraction(),n=i*r.duration,r._buffered!==n&&(r._buffered=n,r.buffered.length=1,e(t).trigger("progress")),i>.99&&(r.networkState=1),r.readyState<4&&r.currentTime&&(r._buffered-r.currentTime>9||i>.9)&&(r.readyState=4,p(r._elem,"canplaythrough")))},o=function(){if(r._ytAPI&&r._ytAPI.getCurrentTime){var n=r._ytAPI.getCurrentTime();r.currentTime!=n&&(r.currentTime=n,e(t).trigger("timeupdate")),s()}},u=function(){if(r.isActive=="third"&&r._ytAPI&&r._ytAPI.getVolume){var n=r._ytAPI.getVolume()/100,i=r._ytAPI.isMuted(),u;n!=r.volume&&(r.volume=n,u=!0),i!=r.muted&&(r.muted=i,u=!0),o(),s(),u&&e(t).trigger("volumechange")}},a=function(){clearInterval(r._timeInterval),r._timeInterval=setInterval(function(){var n=r._ytAPI.getCurrentTime();r.currentTime!=n&&(r.currentTime=n,e(t).trigger("timeupdate"))},350)};r._ytAPI=new YT.Player(n,{height:"100%",width:"100%",playerVars:{allowfullscreen:!0,fs:1,rel:0,showinfo:0,autohide:1,controls:e.prop(t,"controls")?1:0},videoId:i,events:{onReady:function(e){y(r),setTimeout(u,9),setInterval(u,5e3)},onStateChange:function(n){if(!n.target.getDuration)return;var i;if(!r._metadata){var s=n.target.getDuration();s&&(r._metadata=!0,r.duration=s,r.readyState<1&&(r.readyState=1),r.networkState<1&&(r.networkState=2),i=!0)}i&&e(t).trigger("durationchange").trigger("loadedmetadata"),setTimeout(u,9),n.data==1?(w("playing",r),a()):n.data==2?(clearInterval(r._timeInterval),w("pause",r)):n.data==3?(r.readyState>2&&(r.readyState=2),r.networkState=2,e(t).trigger("waiting")):n.data===0&&(r.readyState>4&&(r.readyState=4),r.networkState=1,clearInterval(r._timeInterval),e(t).trigger("ended"))}}}),e(t).on("updateytdata",u)})};o.createSWF=function(n,r,i){i||(i=t.data(n,"mediaelement"));var s=g(r.src);if(i){o.setActive(n,"third",i),d(i),i.currentSrc=r.srcProp,u.done(function(){i._ytAPI.loadVideoById&&i._ytAPI.loadVideoById(s)});return}var a=e.prop(n,"controls"),f="yt-"+t.getID(n),l=e('<div class="polyfill-video polyfill-mediaelement" id="wrapper-'+f+'"><div id="'+f+'"></div>').css({position:"relative",overflow:"hidden"});i=t.data(n,"mediaelement",t.objectCreate(h,{shadowElem:{value:l},_elem:{value:n},currentSrc:{value:r.srcProp},buffered:{value:{start:function(e){if(e>=i.buffered.length){t.error("buffered index size error");return}return 0},end:function(e){if(e>=i.buffered.length){t.error("buffered index size error");return}return i._buffered},length:0}}})),v(i),l.insertBefore(n),t.addShadowDom(n,l),o.setActive(n,"third",i),b(n),E(n,f,i,s),e(n).on("updatemediaelementdimensions updateshadowdom",function(){v(i)})},function(){var n=function(t){clearTimeout(t.updateDataTimer),t.updateDataTimer=setTimeout(function(){e(t._elem).triggerHandler("updateytdata")},9)},r={},i,s=function(e){r[e]={get:function(){var t=m(this);return t?t[e]:i[e].prop._supget.apply(this)},writeable:!1}},o=function(e,t){s(e),delete r[e].writeable,r[e].set=t};f.forEach(s),o("currentTime",function(e){var t=m(this);if(!t)return i.currentTime.prop._supset.apply(this,arguments);e*=1,!isNaN(e)&&t._ytAPI&&t._ytAPI.seekTo&&(t._ytAPI.seekTo(e),n(t))}),o("muted",function(e){var t=m(this);if(!t)return i.muted.prop._supset.apply(this,arguments);t._ytAPI&&t._ytAPI.mute&&(t._ytAPI[e?"mute":"unMute"](),n(t))}),o("volume",function(e){var r=m(this);if(!r)return i.volume.prop._supset.apply(this,arguments);e*=100,!isNaN(e)&&r._ytAPI&&r._ytAPI.setVolume&&((e<0||e>100)&&t.error("volume greater or less than allowed "+e/100),r._ytAPI.setVolume(e),n(r))}),e.each(["play","pause"],function(e,t){var n=t+"Video";r[t]={value:function(){var e=m(this);if(!e)return i[t].prop._supvalue.apply(this,arguments);e._ytAPI&&e._ytAPI[n]&&(e._ytAPI[n](),w(t,e))}}}),i=t.defineNodeNameProperties("video",r,"prop")}()});
\ No newline at end of file