text: 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={html5:"third",third:"html5"},u=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():(i.isActive=o[i.isActive],e(r.target).pause(),i.isActive=o[i.isActive])))};b=function(n){e(n).off(s).on(s,u),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,i,s){s||(s=t.data(n,"mediaelement"));var a=g(i.src);if(s){o.setActive(n,"third",s),d(s),s.currentSrc=i.srcProp,u.done(function(){s._ytAPI.loadVideoById&&s._ytAPI.loadVideoById(a)});return}var f=e.prop(n,"controls"),l="yt-"+t.getID(n),c=e('<div class="polyfill-video polyfill-mediaelement" id="wrapper-'+l+'"><div id="'+l+'"></div>').css({position:"relative",overflow:"hidden"}),p=function(){v(s)};s=t.data(n,"mediaelement",t.objectCreate(h,{shadowElem:{value:c},_elem:{value:n},currentSrc:{value:i.srcProp},buffered:{value:{start:function(e){if(e>=s.buffered.length){t.error("buffered index size error");return}return 0},end:function(e){if(e>=s.buffered.length){t.error("buffered index size error");return}return s._buffered},length:0}}})),v(s),c.insertBefore(n),t.addShadowDom(n,c),o.setActive(n,"third",s),b(n),E(n,l,s,a),e(r).on("updateshadowdom",p),e(n).on("updatemediaelementdimensions",p)},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")}()});