LocalCDN-Firefox-Chrome-Brave/resources/embedly-player/0.1.0/embedly-player.min.jsm

1 line
14 KiB
JavaScript
Raw Normal View History

2021-05-01 06:23:14 +02:00
!function(a,b){function c(a){return function(){var b={method:a},c=Array.prototype.slice.call(arguments);/^get/.test(a)?(d.assert(c.length>0,"Get methods require a callback."),c.unshift(b)):(/^set/.test(a)&&(d.assert(0!==c.length,"Set methods require a value."),b.value=c[0]),c=[b]),this.send.apply(this,c)}}var d={};d.DEBUG=!1,d.VERSION="0.0.11",d.CONTEXT="player.js",d.POST_MESSAGE=!!a.postMessage,d.origin=function(b){return"//"===b.substr(0,2)&&(b=a.location.protocol+b),b.split("/").slice(0,3).join("/")},d.addEvent=function(a,b,c){a&&(a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c)},d.log=function(){d.log.history=d.log.history||[],d.log.history.push(arguments),a.console&&d.DEBUG&&a.console.log(Array.prototype.slice.call(arguments))},d.isString=function(a){return"[object String]"===Object.prototype.toString.call(a)},d.isObject=function(a){return"[object Object]"===Object.prototype.toString.call(a)},d.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},d.isNone=function(a){return null===a||void 0===a},d.has=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},d.indexOf=function(a,b){if(null==a)return-1;var c=0,d=a.length;if(Array.prototype.IndexOf&&a.indexOf===Array.prototype.IndexOf)return a.indexOf(b);for(;d>c;c++)if(a[c]===b)return c;return-1},d.assert=function(a,b){if(!a)throw b||"Player.js Assert Failed"},d.Keeper=function(){this.init()},d.Keeper.prototype.init=function(){this.data={}},d.Keeper.prototype.getUUID=function(){return"listener-xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"===a?b:3&b|8;return c.toString(16)})},d.Keeper.prototype.has=function(a,b){if(!this.data.hasOwnProperty(a))return!1;if(d.isNone(b))return!0;for(var c=this.data[a],e=0;e<c.length;e++)if(c[e].id===b)return!0;return!1},d.Keeper.prototype.add=function(a,b,c,d,e){var f={id:a,event:b,cb:c,ctx:d,one:e};this.has(b)?this.data[b].push(f):this.data[b]=[f]},d.Keeper.prototype.execute=function(a,b,c,e){if(!this.has(a,b))return!1;for(var f=[],g=[],h=0;h<this.data[a].length;h++){var i=this.data[a][h];d.isNone(b)||!d.isNone(b)&&i.id===b?(g.push({cb:i.cb,ctx:i.ctx?i.ctx:e,data:c}),i.one===!1&&f.push(i)):f.push(i)}0===f.length?delete this.data[a]:this.data[a]=f;for(var j=0;j<g.length;j++){var k=g[j];k.cb.call(k.ctx,k.data)}},d.Keeper.prototype.on=function(a,b,c,d){this.add(a,b,c,d,!1)},d.Keeper.prototype.one=function(a,b,c,d){this.add(a,b,c,d,!0)},d.Keeper.prototype.off=function(a,b){var c=[];if(!this.data.hasOwnProperty(a))return c;for(var e=[],f=0;f<this.data[a].length;f++){var g=this.data[a][f];d.isNone(b)||g.cb===b?d.isNone(g.id)||c.push(g.id):e.push(g)}return 0===e.length?delete this.data[a]:this.data[a]=e,c},d.Player=function(a,b){return this instanceof d.Player?void this.init(a,b):new d.Player(a,b)},d.EVENTS={READY:"ready",PLAY:"play",PAUSE:"pause",ENDED:"ended",TIMEUPDATE:"timeupdate",PROGRESS:"progress",ERROR:"error"},d.EVENTS.all=function(){var a=[];for(var b in d.EVENTS)d.has(d.EVENTS,b)&&d.isString(d.EVENTS[b])&&a.push(d.EVENTS[b]);return a},d.METHODS={PLAY:"play",PAUSE:"pause",GETPAUSED:"getPaused",MUTE:"mute",UNMUTE:"unmute",GETMUTED:"getMuted",SETVOLUME:"setVolume",GETVOLUME:"getVolume",GETDURATION:"getDuration",SETCURRENTTIME:"setCurrentTime",GETCURRENTTIME:"getCurrentTime",SETLOOP:"setLoop",GETLOOP:"getLoop",REMOVEEVENTLISTENER:"removeEventListener",ADDEVENTLISTENER:"addEventListener"},d.METHODS.all=function(){var a=[];for(var b in d.METHODS)d.has(d.METHODS,b)&&d.isString(d.METHODS[b])&&a.push(d.METHODS[b]);return a},d.READIED=[],d.Player.prototype.init=function(c,e){var f=this;d.isString(c)&&(c=b.getElementById(c)),this.elem=c,d.assert("IFRAME"===c.nodeName,'playerjs.Player constructor requires an Iframe, got "'+c.nodeName+'"'),d.assert(c.src,"playerjs.Player constructor requires a Iframe with a 'src' attribute."),this.origin=d.origin(c.src),this.keeper=new d.Keeper,this.isReady=!1,this.queue=[],this.events=d.EVENTS.all(),this.methods=d.METHODS.all(),d.POST_MESSAGE?d.addEvent(a,"message",function(a){f.recei