jwplayer-video-element
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -19,3 +19,3 @@ (()=>{async function u(s,t){return t&&self[t]?self[t]:new Promise(function(o,e){let i=document.createElement("script");i.src=s,i.onload=()=>o(self[t]),i.onerror=e,document.head.appendChild(i)})}function h(s){return(...t)=>new Promise(o=>{s(...t,(...e)=>{e.length>1?o(e):o(e[0])})})}function n(){let s,t,o=new Promise(function(e,i){s=e,t=i});return o.resolve=(...e)=>(o.resolved=!0,s(...e),o),o.reject=(...e)=>(t(...e),o),o}var c=class extends HTMLElement{constructor(){super();this.ready=n()}get nativeEl(){return this.querySelector("video")}static get observedAttributes(){let t=[];Object.getOwnPropertyNames(this.prototype).forEach(e=>{let i=!1;try{typeof this.prototype[e]=="function"&&(i=!0)}catch{}!i&&e!==e.toUpperCase()&&t.push(e.toLowerCase())});let o=Object.getPrototypeOf(this).observedAttributes;return o&&(t=t.concat(o)),t}async attributeChangedCallback(t,o,e){this.ready.resolved||await this.ready;let i=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),r=g(i,t),d=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;r&&!d?typeof this[r]=="boolean"?e===null?this[r]=!1:this[r]=!0:this[r]=e:e===null?this.nativeEl.removeAttribute(t):["id","class"].indexOf(t)===-1&&this.nativeEl.setAttribute(t,e)}},l=[],p=document.createElement("video"),b=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let s=Object.getPrototypeOf(p);s&&s!==HTMLElement.prototype;s=Object.getPrototypeOf(s))Object.keys(s).forEach(t=>{b.indexOf(t)===-1&&l.push(t)});l=l.concat(Object.keys(EventTarget.prototype));l.forEach(s=>{if(typeof p[s]=="function")c.prototype[s]=async function(){return this.ready.resolved||await this.ready,this.nativeEl[s].apply(this.nativeEl,arguments)};else{let o={get(){return this.nativeEl?.[s]}};s!==s.toUpperCase()&&(o.set=async function(e){this.ready.resolved||await this.ready,this.nativeEl[s]=e}),Object.defineProperty(c.prototype,s,o)}});function g(s,t){let o=null;return s.forEach(e=>{e.toLowerCase()==t.toLowerCase()&&(o=e)}),o}var f=c;var y=document.createElement("template");y.innerHTML=` | ||
<slot></slot> | ||
`;var a=class extends f{constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.append(m.content.cloneNode(!0))}get nativeEl(){return this.querySelector(".jw-video")}async load(){this.ready=n();let t=/jwplayer\.com\/players\/(\w+)(?:-(\w+))?/i,[,o,e]=this.src.match(t),i=`https://cdn.jwplayer.com/v2/media/${o}`,r=await(await fetch(i)).json(),d=`https://content.jwplatform.com/libraries/${e}.js`,w=await u(d,"jwplayer");this.textContent="",this.append(y.content.cloneNode(!0)),this.api=w(this.querySelector("div")).setup({width:"100%",height:"100%",preload:this.getAttribute("preload")??"metadata",...r}),await h(this.api.on,this.api)("ready"),this.api.getContainer().classList.toggle("jw-no-controls",!this.controls),this.ready.resolve(),this.dispatchEvent(new Event("ready")),this.volume=1}async attributeChangedCallback(t,o,e){if(t==="src"&&e){this.load();return}switch(super.attributeChangedCallback(t,o,e),await this.ready,t){case"controls":this.api.getContainer().classList.toggle("jw-no-controls",!this.controls);break;case"muted":this.muted=this.getAttribute("muted")!=null;break}}get src(){return this.getAttribute("src")}set src(t){this.src!=t&&this.setAttribute("src",t)}set controls(t){this.controls!=t&&(t?this.setAttribute("controls",""):this.removeAttribute("controls"))}get controls(){return this.getAttribute("controls")!=null}};window.customElements.get("jwplayer-video")||window.JWPlayerVideoElement?console.debug("JWPlayerVideoElement: <jwplayer-video> defined more than once."):(window.JWPlayerVideoElement=a,window.customElements.define("jwplayer-video",a));var C=a;})(); | ||
`;var a=class extends f{constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.append(m.content.cloneNode(!0))}get nativeEl(){return this.querySelector(".jw-video")}async load(){this.ready=n();let t=/jwplayer\.com\/players\/(\w+)(?:-(\w+))?/i,[,o,e]=this.src.match(t),i=`https://cdn.jwplayer.com/v2/media/${o}`,r=await(await fetch(i)).json(),d=`https://content.jwplatform.com/libraries/${e}.js`,w=await u(d,"jwplayer");this.textContent="",this.append(y.content.cloneNode(!0)),this.api=w(this.querySelector("div")).setup({width:"100%",height:"100%",preload:this.getAttribute("preload")??"metadata",...r}),await h(this.api.on,this.api)("ready"),this.api.getContainer().classList.toggle("jw-no-controls",!this.controls),this.ready.resolve(),this.dispatchEvent(new Event("ready")),this.volume=1}async attributeChangedCallback(t,o,e){if(t==="src"&&e){this.load();return}switch(super.attributeChangedCallback(t,o,e),await this.ready,t){case"controls":this.api.getContainer().classList.toggle("jw-no-controls",!this.controls);break;case"muted":this.muted=this.getAttribute("muted")!=null;break}}get paused(){return this.nativeEl?.paused??!0}get src(){return this.getAttribute("src")}set src(t){this.src!=t&&this.setAttribute("src",t)}set controls(t){this.controls!=t&&(t?this.setAttribute("controls",""):this.removeAttribute("controls"))}get controls(){return this.getAttribute("controls")!=null}};window.customElements.get("jwplayer-video")||window.JWPlayerVideoElement?console.debug("JWPlayerVideoElement: <jwplayer-video> defined more than once."):(window.JWPlayerVideoElement=a,window.customElements.define("jwplayer-video",a));var C=a;})(); | ||
//# sourceMappingURL=jwplayer-video-element.js.map |
{ | ||
"name": "jwplayer-video-element", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Custom element (web component) for the JW player.", |
@@ -96,2 +96,6 @@ import VideoBaseElement from './video-base-element.js'; | ||
get paused() { | ||
return this.nativeEl?.paused ?? true; | ||
} | ||
get src() { | ||
@@ -98,0 +102,0 @@ return this.getAttribute('src'); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34240
360