agenda-libre-ruby/public/webshims/1.15.9/shims/mediaelement-yt.js

1 line
10 KiB
JavaScript
Raw Normal View History

webshims.register("mediaelement-yt",function(a,b,c,d,e){"use strict";var f=b.mediaelement,g=a.Deferred(),h=function(){c.YT||b.loader.loadScript("https://www.youtube.com/player_api"),h=a.noop},i=c.Modernizr,j=(!i||!i.videoautoplay)&&/iP(hone|od|ad)|android/i.test(navigator.userAgent);c.onYouTubePlayerAPIReady=function(){g.resolve(),h=a.noop},c.YT&&YT.Player&&c.onYouTubePlayerAPIReady();var k={paused:!0,ended:!1,currentSrc:"",duration:c.NaN,readyState:0,networkState:0,videoHeight:0,videoWidth:0,error:null,buffered:{start:function(a){return a?void b.error("buffered index size error"):0},end:function(a){return a?void b.error("buffered index size error"):0},length:0}},l=Object.keys(k),m={currentTime:0,volume:1,muted:!1},n=a.extend({isActive:"html5",activating:"html5",wasSwfReady:!1,_metadata:!1,_callMeta:!1,currentTime:0,_buffered:0,_ppFlag:e},k,m),o=function(b,c){c=a.Event(c),c.preventDefault(),a.event.trigger(c,e,b)},p=function(){var a=["_buffered","_metadata","_ppFlag","currentSrc","currentTime","duration","ended","networkState","paused","videoHeight","videoWidth","_callMeta"],b=a.length;return function(c){if(c){var d=b,e=c.networkState;for(c.readyState=0;--d;)delete c[a[d]];c.buffered.length=0,clearInterval(c._timeInterval),e&&o(c._elem,"emptied")}}}(),q=function(){var b={},e=function(c){var e,f,g;return b[c.currentSrc]?e=b[c.currentSrc]:c.videoHeight&&c.videoWidth?(b[c.currentSrc]={width:c.videoWidth,height:c.videoHeight},e=b[c.currentSrc]):(f=a.attr(c._elem,"poster"))&&(e=b[f],e||(g=d.createElement("img"),g.onload=function(){b[f]={width:this.width,height:this.height},b[f].height&&b[f].width?r(c,a.prop(c._elem,"controls")):delete b[f],g.onload=null},g.src=f,g.complete&&g.onload&&g.onload())),e||{width:300,height:"video"==c._elemNodeName?150:50}},f=function(a,b){return a.style[b]||a.currentStyle&&a.currentStyle[b]||c.getComputedStyle&&(c.getComputedStyle(a,null)||{})[b]||""},g=["minWidth","maxWidth","minHeight","maxHeight"],h=function(a,b){var c,d,e=!1;for(c=0;4>c;c++)d=f(a,g[c]),parseFloat(d,10)&&(e=!0,b[g[c]]=d);return e},i=function(b){var c,d,g=b._elem,i={width:"auto"==f(g,"width"),height:"auto"==f(g,"height")},j={width:!i.width&&a(g).width(),height:!i.height&&a(g).height()};return(i.width||i.height)&&(c=e(b),d=c.width/c.height,i.width&&i.height?(j.width=c.width,j.height=c.height):i.width?j.width=j.height*d:i.height&&(j.height=j.width/d),h(g,j)&&(b.shadowElem.css(j),i.width&&(j.width=b.shadowElem.height()*d),i.height&&(j.height=(i.width?j.width:b.shadowElem.width())/d),i.width&&i.height&&(b.shadowElem.css(j),j.height=b.shadowElem.width()/d,j.width=j.height*d,b.shadowElem.css(j),j.width=b.shadowElem.height()*d,j.height=j.width/d))),j};return i}(),r=function(a){var b,d=a.shadowElem;"third"==a.isActive&&(a&&a._ytAPI&&a._ytAPI.getPlaybackQuality&&(c.ytapi=a._ytAPI),a._elem.style.display="",b=q(a),a._elem.style.display="none",d.css(b))},s=function(a){try{a.nodeName}catch(c){return null}var d=b.data(a,"mediaelement");return d&&"third"==d.isActive?d:null},t=/vq\=(small|medium|large|hd720|hd1080|highres)/i,u=function(c){var d,e=(c.match(t)||["",""])[1].toLowerCase();return c=c.split("?"),-1!=c[0].indexOf("youtube.com/watch")&&c[1]?(c=c[1].split("&"),a.each(c,function(a,b){return b=b.split("="),"v"==b[0]?(c=b[1],d=!0,!1):void 0})):-1!=c[0].indexOf("youtube.com/v/")&&(c=c[0].split("/"),a.each(c,function(a,b){return d?(c=b,!1):void("v"==b&&(d=!0))})),d||b.error("no youtube id found: "+c),{videoId:c,suggestedQuality:e}},v=function(b){b&&(b._ppFlag===e&&a.prop(b._elem,"autoplay")||!b.paused)&&setTimeout(function(){if("third"==b.isActive&&(b._ppFlag===e||!b.paused))try{a(b._elem).play()}catch(c){}},1)},w=a.noop;!function(){var c={play:1,playing:1},e=["play","pause","playing","canplay","progress","waiting","ended","loadedmetadata","loadstart","durationchange","emptied"],f=e.map(function(a){return a+".webshimspolyfill"}).join(" "),g=function(d){var e=b.data(d.target,"mediaelement");if(e){var f=d.originalEvent&&d.originalEvent.type===d.type;f==("third"==e.activating)&&(d.stopImmediatePropagation(),c[d.type]&&e.isActive!=e.activating&&