@slashedcloud/player
Version:
A media player application utilizing Shaka Player for adaptive video streaming, capable of playing HLS, MPD and plain HTTP video streams.
6 lines (5 loc) • 3.55 kB
JavaScript
var A=Object.defineProperty;var y=s=>{throw TypeError(s)};var L=(s,e,r)=>e in s?A(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var o=(s,e,r)=>L(s,typeof e!="symbol"?e+"":e,r),U=(s,e,r)=>e.has(s)||y("Cannot "+r);var P=(s,e,r)=>e.has(s)?y("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,r);var f=(s,e,r)=>(U(s,e,"access private method"),r);var m=(s,e,r)=>new Promise((l,p)=>{var d=a=>{try{t(r.next(a))}catch(i){p(i)}},I=a=>{try{t(r.throw(a))}catch(i){p(i)}},t=a=>a.done?l(a.value):Promise.resolve(a.value).then(d,I);t((r=r.apply(s,e)).next())});/*!
* SlashedCloud v0.1.2 (https://github.com/SlashedCloud/player#readme)
* Copyright 2024-2024 rogerio.jardim@fedrax.pt
* Licensed under Apache (https://github.com/SlashedCloud/player/blob/develop/LICENSE)
*/this.SlashedCloudPlayer=this.SlashedCloudPlayer||{};this.SlashedCloudPlayer.PopUp=function(){"use strict";var d,C;class s{constructor(a){o(this,"player");this.player=a}}const e=t=>Object.prototype.toString.call(t)==="[object Object]";var r=(t=>(t[t.INFO=0]="INFO",t[t.WARNING=1]="WARNING",t[t.ERROR=2]="ERROR",t[t.CRITICAL=3]="CRITICAL",t[t.FATAL=4]="FATAL",t))(r||{});class l extends Error{constructor(i,c,h,n){super(h);P(this,d);o(this,"name");o(this,"message");o(this,"severity");o(this,"code");o(this,"description");o(this,"reason");this.name=i,this.message=h,this.severity=c,this.code=n==null?void 0:n.code,this.description=n==null?void 0:n.description,this.reason=n==null?void 0:n.reason,f(this,d,C).call(this)}get severityString(){switch(this.severity){case 3:return"CRITICAL";case 2:return"ERROR";case 1:return"WARNING";case 0:default:return"INFO"}}toObject(){return{errorName:this.name,errorMessage:this.message,errorSeverity:this.severityString,errorCode:this.code,errorDescription:this.description,errorReason:this.reason}}}d=new WeakSet,C=function(){var c,h,n;let i=`${this.severityString}: ${this.name} | ${this.message}`;switch(this.description&&(i+=` | ${this.description}`),this.code&&(i+=` [${this.code}]`),this.severity){case 0:console.info(i,(c=this.reason)!=null?c:"");break;case 1:console.warn(i,(h=this.reason)!=null?h:"");break;case 2:case 3:case 4:default:console.error(i,(n=this.reason)!=null?n:"");break}};class p extends s{constructor(i,c){super(i);o(this,"name","PopUpPlugin");o(this,"options");o(this,"clickCounter");o(this,"alreadyShowPopUp");this.clickCounter=1,this.alreadyShowPopUp=!1,this.options=c}setup(){return m(this,null,function*(){if(!this.options||!e(this.options))throw new l(this.name,r.ERROR,"The options are missing or not clearly defined.",{description:"Provide the necessary options to complete the setup process."});if(!this.options.url)throw new l(this.name,r.ERROR,"The options URL is required",{description:"A URL is needed to complete the setup. Please provide a valid URL to proceed."});this.player.container.addEventListener("click",this.handleInteraction.bind(this),{capture:!0}),this.player.container.addEventListener("touchend",this.handleInteraction.bind(this),{capture:!0})})}handleInteraction(i){var h;if(this.alreadyShowPopUp||i.type!=="touchend")return;const c=(h=this.options.clicks)!=null?h:1;if(this.clickCounter>=c){i.stopPropagation();const{open:n,url:O,width:R,height:g,features:w}=this.options,u=[];if(n==="window"){const k=R!=null?R:screen.width,b=g!=null?g:screen.height;u.push(`width=${k}`),u.push(`height=${b}`),w&&u.push(w)}window.open(O,"_blank",u.join(",")),this.alreadyShowPopUp=!0,this.player.emit("popUpOpened")}this.clickCounter+=1}}return p}();