@gumlet/player.js 2.0.9 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@gumlet/player.js","version":"2.0.9","description":"Gumlet Player.JS allows you to control gumlet player from your website","license":"MIT","repository":{"type":"git","url":"https://github.com/gumlet/player.js"},"main":"player.js","readme":"Please visit: https://github.com/gumlet/player.js/blob/main/README.md","author":"Gumlet Pte. Ltd.","homepage":"https://github.com/gumlet/player.js/blob/main/README.md","bugs":{"url":"https://www.gumlet.com/contact/"},"maintainers":[{"name":"Gumlet Team","email":"support@gumlet.com"}]}
1
+ {"name":"@gumlet/player.js","version":"2.0.11","description":"Gumlet Player.JS allows you to control gumlet player from your website","license":"MIT","repository":{"type":"git","url":"https://github.com/gumlet/player.js"},"main":"player.js","readme":"Please visit: https://github.com/gumlet/player.js/blob/main/README.md","author":"Gumlet Pte. Ltd.","homepage":"https://github.com/gumlet/player.js/blob/main/README.md","bugs":{"url":"https://www.gumlet.com/contact/"},"maintainers":[{"name":"Gumlet Team","email":"support@gumlet.com"}]}
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see player.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(self,(function(){return function(){"use strict";var e={d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:function(){return p}});const n={EVENTS:{READY:"ready",PLAY:"play",PAUSE:"pause",ENDED:"ended",TIMEUPDATE:"timeupdate",PROGRESS:"progress",SEEKED:"seeked",ERROR:"error",FULLSCREEN_CHANGE:"fullscreenChange",PIP_CHANGE:"pipChange",PLAYBACK_RATE_CHANGE:"playbackRateChange",AUDIO_CHANGE:"audioChange",QUALITY_CHANGE:"qualityChange",VOLUME_CHANGE:"volumeChange"},POST_MESSAGE:!!window.postMessage,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",SETPLAYBACKRATE:"setPlaybackRate",GETPLAYBACKRATE:"getPlaybackRate",REMOVEEVENTLISTENER:"removeEventListener",ADDEVENTLISTENER:"addEventListener"},DEBUG:!1,VERSION:"2.0",CONTEXT:"player.js",isString:function(e){return"[object String]"===Object.prototype.toString.call(e)},has:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}};n.METHODS.all=function(){const e=[];for(const t in n.METHODS)n.has(n.METHODS,t)&&n.isString(n.METHODS[t])&&e.push(n.METHODS[t]);return e},n.EVENTS.all=function(){const e=[];for(const t in n.EVENTS)n.has(n.EVENTS,t)&&n.isString(n.EVENTS[t])&&e.push(n.EVENTS[t]);return e},n.addEvent=function(e,t,n){e&&(e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n)},n.isNone=function(e){return null==e},n.assert=function(e,t){if(!e)throw t||"Player.js Assert Failed"},n.generateUUID=function(){if(crypto&&crypto.randomUUID)return crypto.randomUUID();{const e=URL.createObjectURL(new Blob);return e.substring(e.lastIndexOf("/")+1)}},n.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)};var o=n;var i=class{constructor(){this.data={}}has(e,t){if(!Object.hasOwn(this.data,e))return!1;if(o.isNone(t))return!0;const n=this.data[e];for(let e=0;e<n.length;e++)if(n[e].id===t)return!0;return!1}add(e,t,n,o,i){const s={id:e,event:t,cb:n,ctx:o,one:i};this.has(t)?this.data[t].push(s):this.data[t]=[s]}execute(e,t,n,i){if(!this.has(e,t))return!1;const s=[],r=[];for(let a=0;a<this.data[e].length;a++){const u=this.data[e][a];o.isNone(t)||!o.isNone(t)&&u.id===t?(r.push({cb:u.cb,ctx:u.ctx?u.ctx:i,data:n}),!1===u.one&&s.push(u)):s.push(u)}0===s.length?delete this.data[e]:this.data[e]=s;for(let e=0;e<r.length;e++){const t=r[e];t.cb.call(t.ctx,t.data)}}on(e,t,n,o){this.add(e,t,n,o,!1)}one(e,t,n,o){this.add(e,t,n,o,!0)}off(e,t){const n=[];if(!Object.hasOwn(this.data,e))return n;const i=[];for(let s=0;s<this.data[e].length;s++){const r=this.data[e][s];o.isNone(t)||r.cb===t?o.isNone(r.id)||n.push(r.id):i.push(r)}return 0===i.length?delete this.data[e]:this.data[e]=i,n}};const s=[];class r{constructor(e){const t=this;this.READIED=s,o.isString(e)&&(e=document.getElementById(e)),this.elem=e,o.assert("IFRAME"===e.nodeName,'playerjs.Player constructor requires an Iframe, got "'+e.nodeName+'"'),o.assert(e.src,"playerjs.Player constructor requires a Iframe with a 'src' attribute."),this.origin=new URL(e.src).origin,this.keeper=new i,this.isReady=!1,this.queue=[],this.events=o.EVENTS.all(),this.methods=o.METHODS.all(),o.POST_MESSAGE?o.addEvent(window,"message",(function(e){t.receive(e)})):console.error("Post Message is not Available."),s.includes(e.src)?t.loaded=!0:this.elem.onload=function(){t.loaded=!0}}send(e,t,n){if(e.context=o.CONTEXT,e.version=o.VERSION,t){const i=o.generateUUID();e.listener=i,this.keeper.one(i,e.method,t,n)}return this.isReady||"ready"===e.value?(console.debug("Player.send",e,this.origin),!0===this.loaded&&this.elem.contentWindow.postMessage(JSON.stringify(e),this.origin),!0):(console.debug("Player.queue",e),this.queue.push(e),!1)}receive(e){if(console.debug("Player.receive",e),e.origin!==this.origin)return!1;let t;try{t=JSON.parse(e.data)}catch(e){return!1}if(t.context!==o.CONTEXT)return!1;"ready"===t.event&&t.value&&t.value.src===this.elem.src&&this.ready(t),this.keeper.has(t.event,t.listener)&&this.keeper.execute(t.event,t.listener,t.value,this)}ready(e){if(!0===this.isReady)return!1;e.value.events&&(this.events=e.value.events),e.value.methods&&(this.methods=e.value.methods),this.isReady=!0,this.loaded=!0;for(let t=0;t<this.queue.length;t++){const n=this.queue[t];console.debug("Player.dequeue",n),"ready"===e.event&&this.keeper.execute(n.event,n.listener,!0,this),this.send(n)}this.queue=[]}on(e,t,n){const i=o.generateUUID();return"ready"===e?this.keeper.one(i,e,t,n):this.keeper.on(i,e,t,n),this.send({method:"addEventListener",value:e,listener:i}),!0}off(e,t){const n=this.keeper.off(e,t);if(console.debug("Player.off",n),n.length>0){for(const t in n)this.send({method:"removeEventListener",value:e,listener:n[t]});return!0}return!1}supports(e,t){o.assert(["method","event"].includes(e),'evtOrMethod needs to be either "event" or "method" got '+e),t=o.isArray(t)?t:[t];const n="event"===e?this.events:this.methods;for(let e=0;e<t.length;e++)if(!n.includes(t[e]))return!1;return!0}}function a(e){return function(){const t={method:e};let n=Array.prototype.slice.call(arguments);/^get/.test(e)?(o.assert(n.length>0,"Get methods require a callback."),n.unshift(t)):(/^set/.test(e)&&(o.assert(0!==n.length,"Set methods require a value."),t.value=n[0]),n=[t]),this.send.apply(this,n)}}for(const e of o.METHODS.all())Object.hasOwn(r.prototype,e)||(r.prototype[e]=a(e));o.addEvent(window,"message",(function(e){let t;try{t=JSON.parse(e.data)}catch(e){return!1}if(t.context!==o.CONTEXT)return!1;"ready"===t.event&&t.value&&t.value.src&&s.push(t.value.src)}));var u=r;var c=class{constructor(e,t){const n=this;this.isReady=!1,this.origin=new URL(document.referrer).origin,this.methods={},this.supported={events:e||o.EVENTS.all(),methods:t||o.METHODS.all()},this.eventListeners={},this.reject=!(window.self!==window.top&&o.POST_MESSAGE),this.reject||o.addEvent(window,"message",(function(e){n.receive(e)}))}receive(e){if(e.origin!==this.origin)return!1;let t={};if("object"==typeof e.data)t=e.data;else try{t=window.JSON.parse(e.data)}catch(e){console.error("JSON Parse Error",e)}if(console.debug("Receiver.receive",e,t),!t.method)return!1;if(t.context!==o.CONTEXT)return!1;if(!o.METHODS.all().includes(t.method))return this.emit("error",{code:2,msg:'Invalid Method "'+t.method+'"'}),!1;const n=o.isNone(t.listener)?null:t.listener;if("addEventListener"===t.method)Object.hasOwn(this.eventListeners,t.value)?this.eventListeners[t.value].includes(n)||this.eventListeners[t.value].push(n):this.eventListeners[t.value]=[n],"ready"===t.value&&this.isReady&&this.ready();else if("removeEventListener"===t.method){if(Object.hasOwn(this.eventListeners,t.value)){const e=this.eventListeners[t.value].indexOf(n);e>-1&&this.eventListeners[t.value].splice(e,1),0===this.eventListeners[t.value].length&&delete this.eventListeners[t.value]}}else this.get(t.method,t.value,n)}get(e,t,n){const o=this;if(!Object.hasOwn(this.methods,e))return this.emit("error",{code:3,msg:'Method Not Supported"'+e+'"'}),!1;const i=this.methods[e];if("get"===e.substr(0,3)){const t=function(t){o.send(e,t,n)};i.call(this,t)}else i.call(this,t)}on(e,t){this.methods[e]=t}send(e,t,n){if(console.debug("Receiver.send",e,t,n),this.reject)return console.error("Receiver.send.reject",e,t,n),!1;const i={context:o.CONTEXT,version:o.VERSION,event:e};o.isNone(t)||(i.value=t),o.isNone(n)||(i.listener=n);const s=JSON.stringify(i);window.parent.postMessage(s,""===this.origin?"*":this.origin)}emit(e,t){if(!Object.hasOwn(this.eventListeners,e))return!1;console.debug("Instance.emit",e,t,this.eventListeners[e]);for(let n=0;n<this.eventListeners[e].length;n++){const o=this.eventListeners[e][n];this.send(e,t,o)}return!0}ready(){console.debug("Receiver.ready"),this.isReady=!0;const e={src:window.location.toString(),events:this.supported.events,methods:this.supported.methods};this.emit("ready",e)||this.send("ready",e)}};var d=class{constructor(){this.init()}init(){const e={duration:20,currentTime:0,interval:null,timeupdate:function(){},volume:100,mute:!1,playing:!1,loop:!1,play:function(){e.interval=setInterval((function(){e.currentTime+=.25,e.timeupdate({seconds:e.currentTime,duration:e.duration})}),250),e.playing=!0},pause:function(){clearInterval(e.interval),e.playing=!1}},t=this.receiver=new c;t.on("play",(function(){const t=this;e.play(),this.emit("play"),e.timeupdate=function(e){t.emit("timeupdate",e)}})),t.on("pause",(function(){e.pause(),this.emit("pause")})),t.on("getPaused",(function(t){t(!e.playing)})),t.on("getCurrentTime",(function(t){t(e.currentTime)})),t.on("setCurrentTime",(function(t){e.currentTime=t})),t.on("getDuration",(function(t){t(e.duration)})),t.on("getVolume",(function(t){t(e.volume)})),t.on("setVolume",(function(t){e.volume=t})),t.on("mute",(function(){e.mute=!0})),t.on("unmute",(function(){e.mute=!1})),t.on("getMuted",(function(t){t(e.mute)})),t.on("getLoop",(function(t){t(e.loop)})),t.on("setLoop",(function(t){e.loop=t})),t.on("setPlaybackRate",(function(t){e.playbackRate=t})),t.on("getPlaybackRate",(function(t){t(e.playbackRate)}))}ready(){this.receiver.ready()}};var l=class{constructor(e){this.init(e)}init(e){o.assert(e,"VideoJSReceiver requires a player object");const t=this.receiver=new c;e.on("pause",(function(){t.emit("pause")})),e.on("play",(function(){t.emit("play")})),e.on("timeupdate",(function(n){const o=e.currentTime(),i=e.duration();if(!o||!i)return!1;const s={seconds:o,duration:i};t.emit("timeupdate",s)})),e.on("ended",(function(){t.emit("ended")})),e.on("error",(function(){t.emit("error")})),t.on("play",(function(){e.play()})),t.on("pause",(function(){e.pause()})),t.on("getPaused",(function(t){t(e.paused())})),t.on("getCurrentTime",(function(t){t(e.currentTime())})),t.on("setCurrentTime",(function(t){e.currentTime(t)})),t.on("getDuration",(function(t){t(e.duration())})),t.on("getVolume",(function(t){t(100*e.volume())})),t.on("setVolume",(function(t){e.volume(t/100)})),t.on("mute",(function(){e.volume(0)})),t.on("unmute",(function(){e.volume(1)})),t.on("getMuted",(function(t){t(0===e.volume())})),t.on("getLoop",(function(t){t(e.loop())})),t.on("setLoop",(function(t){e.loop(t)})),t.on("setPlaybackRate",(function(t){e.playbackRate(t)})),t.on("getPlaybackRate",(function(t){t(e.playbackRate())}))}ready(){this.receiver.ready()}};var h=class{constructor(e){this.init(e)}init(e){o.assert(e,"HTML5Adapter requires a video element");const t=this.receiver=new c;e.addEventListener("playing",(function(){t.emit("play")})),e.addEventListener("pause",(function(){t.emit("pause")})),e.addEventListener("ended",(function(){t.emit("ended")})),e.addEventListener("timeupdate",(function(){t.emit("timeupdate",{seconds:e.currentTime,duration:e.duration})})),e.addEventListener("progress",(function(){t.emit("buffered",{percent:e.buffered.length})})),t.on("play",(function(){e.play()})),t.on("pause",(function(){e.pause()})),t.on("getPaused",(function(t){t(e.paused)})),t.on("getCurrentTime",(function(t){t(e.currentTime)})),t.on("setCurrentTime",(function(t){e.currentTime=t})),t.on("getDuration",(function(t){t(e.duration)})),t.on("getVolume",(function(t){t(100*e.volume)})),t.on("setVolume",(function(t){e.volume=t/100})),t.on("mute",(function(){e.muted=!0})),t.on("unmute",(function(){e.muted=!1})),t.on("getMuted",(function(t){t(e.muted)})),t.on("getLoop",(function(t){t(e.loop)})),t.on("setLoop",(function(t){e.loop=t})),t.on("setPlaybackRate",(function(t){e.playbackRate=t})),t.on("getPlaybackRate",(function(t){t(e.playbackRate)}))}ready(){this.receiver.ready()}};const f={Player:u,Receiver:c,MockAdapter:d,VideoJSAdapter:l,HTML5Adapter:h,CONTEXT:o.CONTEXT,VERSION:o.VERSION,METHODS:o.METHODS,addEvent:o.addEvent};"undefined"!=typeof window&&(window.playerjs=f);var p={playerjs:f};return t}()}));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(self,(function(){return function(){"use strict";var e={d:function(t,n){for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:function(){return p}});const n={EVENTS:{READY:"ready",PLAY:"play",PAUSE:"pause",ENDED:"ended",TIMEUPDATE:"timeupdate",PROGRESS:"progress",SEEKED:"seeked",ERROR:"error",FULLSCREEN_CHANGE:"fullscreenChange",PIP_CHANGE:"pipChange",PLAYBACK_RATE_CHANGE:"playbackRateChange",AUDIO_CHANGE:"audioChange",QUALITY_CHANGE:"qualityChange",VOLUME_CHANGE:"volumeChange"},POST_MESSAGE:!!window.postMessage,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",SETPLAYBACKRATE:"setPlaybackRate",GETPLAYBACKRATE:"getPlaybackRate",REMOVEEVENTLISTENER:"removeEventListener",ADDEVENTLISTENER:"addEventListener"},DEBUG:!1,VERSION:"2.0",CONTEXT:"player.js",isString:function(e){return"[object String]"===Object.prototype.toString.call(e)},has:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}};n.METHODS.all=function(){const e=[];for(const t in n.METHODS)n.has(n.METHODS,t)&&n.isString(n.METHODS[t])&&e.push(n.METHODS[t]);return e},n.EVENTS.all=function(){const e=[];for(const t in n.EVENTS)n.has(n.EVENTS,t)&&n.isString(n.EVENTS[t])&&e.push(n.EVENTS[t]);return e},n.addEvent=function(e,t,n){e&&(e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n)},n.isNone=function(e){return null==e},n.assert=function(e,t){if(!e)throw t||"Player.js Assert Failed"},n.generateUUID=function(){if(crypto&&crypto.randomUUID)return crypto.randomUUID();{const e=URL.createObjectURL(new Blob);return e.substring(e.lastIndexOf("/")+1)}},n.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)};var i=n;var o=class{constructor(){this.data={}}has(e,t){if(!Object.hasOwn(this.data,e))return!1;if(i.isNone(t))return!0;const n=this.data[e];for(let e=0;e<n.length;e++)if(n[e].id===t)return!0;return!1}add(e,t,n,i,o){const s={id:e,event:t,cb:n,ctx:i,one:o};this.has(t)?this.data[t].push(s):this.data[t]=[s]}execute(e,t,n,o){if(!this.has(e,t))return!1;const s=[],r=[];for(let a=0;a<this.data[e].length;a++){const u=this.data[e][a];i.isNone(t)||!i.isNone(t)&&u.id===t?(r.push({cb:u.cb,ctx:u.ctx?u.ctx:o,data:n}),!1===u.one&&s.push(u)):s.push(u)}0===s.length?delete this.data[e]:this.data[e]=s;for(let e=0;e<r.length;e++){const t=r[e];t.cb.call(t.ctx,t.data)}}on(e,t,n,i){this.add(e,t,n,i,!1)}one(e,t,n,i){this.add(e,t,n,i,!0)}off(e,t){const n=[];if(!Object.hasOwn(this.data,e))return n;const o=[];for(let s=0;s<this.data[e].length;s++){const r=this.data[e][s];i.isNone(t)||r.cb===t?i.isNone(r.id)||n.push(r.id):o.push(r)}return 0===o.length?delete this.data[e]:this.data[e]=o,n}};const s=[];class r{constructor(e,t=!1){const n=this;this.READIED=s,i.isString(e)&&(e=document.getElementById(e)),this.elem=e,this.debug=t,i.assert("IFRAME"===e.nodeName,'playerjs.Player constructor requires an Iframe, got "'+e.nodeName+'"'),i.assert(e.src,"playerjs.Player constructor requires a Iframe with a 'src' attribute."),this.origin=new URL(e.src).origin,this.keeper=new o,this.isReady=!1,this.queue=[],this.events=i.EVENTS.all(),this.methods=i.METHODS.all(),i.POST_MESSAGE?i.addEvent(window,"message",(function(e){n.receive(e)})):console.error("Post Message is not Available."),s.includes(e.src)?n.loaded=!0:this.elem.onload=function(){n.loaded=!0}}send(e,t,n){if(e.context=i.CONTEXT,e.version=i.VERSION,t){const o=i.generateUUID();e.listener=o,this.keeper.one(o,e.method,t,n)}return this.isReady||"ready"===e.value?(this.debug&&console.debug("Player.send",e,this.origin),!0===this.loaded&&this.elem.contentWindow.postMessage(JSON.stringify(e),this.origin),!0):(this.debug&&console.debug("Player.queue",e),this.queue.push(e),!1)}receive(e){if(this.debug&&console.debug("Player.receive",e),e.origin!==this.origin)return!1;let t;try{t=JSON.parse(e.data)}catch(e){return!1}if(t.context!==i.CONTEXT)return!1;"ready"===t.event&&t.value&&t.value.src===this.elem.src&&this.ready(t),this.keeper.has(t.event,t.listener)&&this.keeper.execute(t.event,t.listener,t.value,this)}ready(e){if(!0===this.isReady)return!1;e.value.events&&(this.events=e.value.events),e.value.methods&&(this.methods=e.value.methods),this.isReady=!0,this.loaded=!0;for(let t=0;t<this.queue.length;t++){const n=this.queue[t];this.debug&&console.debug("Player.dequeue",n),"ready"===e.event&&this.keeper.execute(n.event,n.listener,!0,this),this.send(n)}this.queue=[]}on(e,t,n){const o=i.generateUUID();return"ready"===e?this.keeper.one(o,e,t,n):this.keeper.on(o,e,t,n),this.send({method:"addEventListener",value:e,listener:o}),!0}off(e,t){const n=this.keeper.off(e,t);if(this.debug&&console.debug("Player.off",n),n.length>0){for(const t in n)this.send({method:"removeEventListener",value:e,listener:n[t]});return!0}return!1}supports(e,t){i.assert(["method","event"].includes(e),'evtOrMethod needs to be either "event" or "method" got '+e),t=i.isArray(t)?t:[t];const n="event"===e?this.events:this.methods;for(let e=0;e<t.length;e++)if(!n.includes(t[e]))return!1;return!0}}function a(e){return function(){const t={method:e};let n=Array.prototype.slice.call(arguments);/^get/.test(e)?(i.assert(n.length>0,"Get methods require a callback."),n.unshift(t)):(/^set/.test(e)&&(i.assert(0!==n.length,"Set methods require a value."),t.value=n[0]),n=[t]),this.send.apply(this,n)}}for(const e of i.METHODS.all())Object.hasOwn(r.prototype,e)||(r.prototype[e]=a(e));i.addEvent(window,"message",(function(e){let t;try{t=JSON.parse(e.data)}catch(e){return!1}if(t.context!==i.CONTEXT)return!1;"ready"===t.event&&t.value&&t.value.src&&s.push(t.value.src)}));var u=r;var c=class{constructor(e,t){const n=this;this.isReady=!1,this.origin=new URL(document.referrer).origin,this.methods={},this.supported={events:e||i.EVENTS.all(),methods:t||i.METHODS.all()},this.eventListeners={},this.reject=!(window.self!==window.top&&i.POST_MESSAGE),this.reject||i.addEvent(window,"message",(function(e){n.receive(e)}))}receive(e){if(e.origin!==this.origin)return!1;let t={};if("object"==typeof e.data)t=e.data;else try{t=window.JSON.parse(e.data)}catch(e){console.error("JSON Parse Error",e)}if(console.debug("Receiver.receive",e,t),!t.method)return!1;if(t.context!==i.CONTEXT)return!1;if(!i.METHODS.all().includes(t.method))return this.emit("error",{code:2,msg:'Invalid Method "'+t.method+'"'}),!1;const n=i.isNone(t.listener)?null:t.listener;if("addEventListener"===t.method)Object.hasOwn(this.eventListeners,t.value)?this.eventListeners[t.value].includes(n)||this.eventListeners[t.value].push(n):this.eventListeners[t.value]=[n],"ready"===t.value&&this.isReady&&this.ready();else if("removeEventListener"===t.method){if(Object.hasOwn(this.eventListeners,t.value)){const e=this.eventListeners[t.value].indexOf(n);e>-1&&this.eventListeners[t.value].splice(e,1),0===this.eventListeners[t.value].length&&delete this.eventListeners[t.value]}}else this.get(t.method,t.value,n)}get(e,t,n){const i=this;if(!Object.hasOwn(this.methods,e))return this.emit("error",{code:3,msg:'Method Not Supported"'+e+'"'}),!1;const o=this.methods[e];if("get"===e.substr(0,3)){const t=function(t){i.send(e,t,n)};o.call(this,t)}else o.call(this,t)}on(e,t){this.methods[e]=t}send(e,t,n){if(console.debug("Receiver.send",e,t,n),this.reject)return console.error("Receiver.send.reject",e,t,n),!1;const o={context:i.CONTEXT,version:i.VERSION,event:e};i.isNone(t)||(o.value=t),i.isNone(n)||(o.listener=n);const s=JSON.stringify(o);window.parent.postMessage(s,""===this.origin?"*":this.origin)}emit(e,t){if(!Object.hasOwn(this.eventListeners,e))return!1;console.debug("Instance.emit",e,t,this.eventListeners[e]);for(let n=0;n<this.eventListeners[e].length;n++){const i=this.eventListeners[e][n];this.send(e,t,i)}return!0}ready(){console.debug("Receiver.ready"),this.isReady=!0;const e={src:window.location.toString(),events:this.supported.events,methods:this.supported.methods};this.emit("ready",e)||this.send("ready",e)}};var d=class{constructor(){this.init()}init(){const e={duration:20,currentTime:0,interval:null,timeupdate:function(){},volume:100,mute:!1,playing:!1,loop:!1,play:function(){e.interval=setInterval((function(){e.currentTime+=.25,e.timeupdate({seconds:e.currentTime,duration:e.duration})}),250),e.playing=!0},pause:function(){clearInterval(e.interval),e.playing=!1}},t=this.receiver=new c;t.on("play",(function(){const t=this;e.play(),this.emit("play"),e.timeupdate=function(e){t.emit("timeupdate",e)}})),t.on("pause",(function(){e.pause(),this.emit("pause")})),t.on("getPaused",(function(t){t(!e.playing)})),t.on("getCurrentTime",(function(t){t(e.currentTime)})),t.on("setCurrentTime",(function(t){e.currentTime=t})),t.on("getDuration",(function(t){t(e.duration)})),t.on("getVolume",(function(t){t(e.volume)})),t.on("setVolume",(function(t){e.volume=t})),t.on("mute",(function(){e.mute=!0})),t.on("unmute",(function(){e.mute=!1})),t.on("getMuted",(function(t){t(e.mute)})),t.on("getLoop",(function(t){t(e.loop)})),t.on("setLoop",(function(t){e.loop=t})),t.on("setPlaybackRate",(function(t){e.playbackRate=t})),t.on("getPlaybackRate",(function(t){t(e.playbackRate)}))}ready(){this.receiver.ready()}};var l=class{constructor(e){this.init(e)}init(e){i.assert(e,"VideoJSReceiver requires a player object");const t=this.receiver=new c;e.on("pause",(function(){t.emit("pause")})),e.on("play",(function(){t.emit("play")})),e.on("timeupdate",(function(n){const i=e.currentTime(),o=e.duration();if(!i||!o)return!1;const s={seconds:i,duration:o};t.emit("timeupdate",s)})),e.on("ended",(function(){t.emit("ended")})),e.on("error",(function(){t.emit("error")})),t.on("play",(function(){e.play()})),t.on("pause",(function(){e.pause()})),t.on("getPaused",(function(t){t(e.paused())})),t.on("getCurrentTime",(function(t){t(e.currentTime())})),t.on("setCurrentTime",(function(t){e.currentTime(t)})),t.on("getDuration",(function(t){t(e.duration())})),t.on("getVolume",(function(t){t(100*e.volume())})),t.on("setVolume",(function(t){e.volume(t/100)})),t.on("mute",(function(){e.volume(0)})),t.on("unmute",(function(){e.volume(1)})),t.on("getMuted",(function(t){t(0===e.volume())})),t.on("getLoop",(function(t){t(e.loop())})),t.on("setLoop",(function(t){e.loop(t)})),t.on("setPlaybackRate",(function(t){e.playbackRate(t)})),t.on("getPlaybackRate",(function(t){t(e.playbackRate())}))}ready(){this.receiver.ready()}};var h=class{constructor(e){this.init(e)}init(e){i.assert(e,"HTML5Adapter requires a video element");const t=this.receiver=new c;e.addEventListener("playing",(function(){t.emit("play")})),e.addEventListener("pause",(function(){t.emit("pause")})),e.addEventListener("ended",(function(){t.emit("ended")})),e.addEventListener("timeupdate",(function(){t.emit("timeupdate",{seconds:e.currentTime,duration:e.duration})})),e.addEventListener("progress",(function(){t.emit("buffered",{percent:e.buffered.length})})),t.on("play",(function(){e.play()})),t.on("pause",(function(){e.pause()})),t.on("getPaused",(function(t){t(e.paused)})),t.on("getCurrentTime",(function(t){t(e.currentTime)})),t.on("setCurrentTime",(function(t){e.currentTime=t})),t.on("getDuration",(function(t){t(e.duration)})),t.on("getVolume",(function(t){t(100*e.volume)})),t.on("setVolume",(function(t){e.volume=t/100})),t.on("mute",(function(){e.muted=!0})),t.on("unmute",(function(){e.muted=!1})),t.on("getMuted",(function(t){t(e.muted)})),t.on("getLoop",(function(t){t(e.loop)})),t.on("setLoop",(function(t){e.loop=t})),t.on("setPlaybackRate",(function(t){e.playbackRate=t})),t.on("getPlaybackRate",(function(t){t(e.playbackRate)}))}ready(){this.receiver.ready()}};const f={Player:u,Receiver:c,MockAdapter:d,VideoJSAdapter:l,HTML5Adapter:h,CONTEXT:i.CONTEXT,VERSION:i.VERSION,METHODS:i.METHODS,addEvent:i.addEvent};"undefined"!=typeof window&&(window.playerjs=f);var p={playerjs:f};return t}()}));
@@ -5,6 +5,6 @@
5
5
  * This source code and its use and distribution, is subject to the terms
6
6
  * and conditions of the applicable license agreement.
7
7
  *
8
- * @gumlet/player.js version 2.0.9
8
+ * @gumlet/player.js version 2.0.11
9
9
  *
10
10
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "title": "Player.js",
3
3
  "name": "@gumlet/player.js",
4
- "version": "2.0.9",
4
+ "version": "2.0.11",
5
5
  "homepage": "http://github.com/gumlet/player.js",
6
6
  "main": "dist/player.min.js",
7
7
  "module": "dist/player.min.js",