UNPKG

@slashedcloud/player

Version:

A media player application utilizing Shaka Player for adaptive video streaming, capable of playing HLS, MPD and plain HTTP video streams.

7 lines (6 loc) 5.27 kB
var R=Object.defineProperty;var f=t=>{throw TypeError(t)};var A=(t,s,i)=>s in t?R(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i;var l=(t,s,i)=>A(t,typeof s!="symbol"?s+"":s,i),N=(t,s,i)=>s.has(t)||f("Cannot "+i);var g=(t,s,i)=>s.has(t)?f("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,i);var k=(t,s,i)=>(N(t,s,"access private method"),i);var x=(t,s,i)=>new Promise((m,c)=>{var h=d=>{try{r(i.next(d))}catch(e){c(e)}},w=d=>{try{r(i.throw(d))}catch(e){c(e)}},r=d=>d.done?m(d.value):Promise.resolve(d.value).then(h,w);r((i=i.apply(t,s)).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.AdOverlay=function(){"use strict";var h,v;var t=document.createElement("style");t.textContent=`.shaka-modal-ad-overlay{position:absolute;top:0;left:0;z-index:1;width:100%;height:100%;background-color:#0006}.shaka-modal-ad-overlay .shaka-modal-ad-content{display:flex;flex-direction:column;align-items:center;justify-content:center;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);max-height:70%;max-width:55%;min-width:550px}.shaka-modal-ad-overlay a{display:block;max-height:calc(100% - 40px)}.shaka-modal-ad-overlay a img{max-width:100%;max-height:100%;height:auto;border:none;border:1px solid #000}.shaka-modal-ad-overlay iframe{display:block;max-width:100%;max-height:100%;height:auto;border:none;overflow:hidden;transform:scale(.6)}@media (min-width: 360px){.shaka-modal-ad-overlay iframe{transform:scale(.8)}}@media (min-width: 480px){.shaka-modal-ad-overlay iframe{transform:scale(1)}}.shaka-modal-ad-overlay .shaka-ad-play-button{display:flex;justify-content:space-evenly;align-items:center;margin:5px auto 0;color:#fff;background-color:#000;border:0px solid #ffffff;border-radius:.1875rem;min-width:100px;cursor:pointer} `,document.head.appendChild(t);class s{constructor(d){l(this,"player");this.player=d}}var i=(r=>(r[r.INFO=0]="INFO",r[r.WARNING=1]="WARNING",r[r.ERROR=2]="ERROR",r[r.CRITICAL=3]="CRITICAL",r[r.FATAL=4]="FATAL",r))(i||{});class m extends Error{constructor(e,n,o,a){super(o);g(this,h);l(this,"name");l(this,"message");l(this,"severity");l(this,"code");l(this,"description");l(this,"reason");this.name=e,this.message=o,this.severity=n,this.code=a==null?void 0:a.code,this.description=a==null?void 0:a.description,this.reason=a==null?void 0:a.reason,k(this,h,v).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}}}h=new WeakSet,v=function(){var n,o,a;let e=`${this.severityString}: ${this.name} | ${this.message}`;switch(this.description&&(e+=` | ${this.description}`),this.code&&(e+=` [${this.code}]`),this.severity){case 0:console.info(e,(n=this.reason)!=null?n:"");break;case 1:console.warn(e,(o=this.reason)!=null?o:"");break;case 2:case 3:case 4:default:console.error(e,(a=this.reason)!=null?a:"");break}};class c extends s{constructor(e,n){super(e);l(this,"name","AdOverlayPlugin");l(this,"isAdPlaying",!1);l(this,"options");this.options=n}setup(){return x(this,null,function*(){var u,y;if(this.options.kind==="iframe"&&!this.options.height)return;this.player.uiConfig.addBigPlayButton=!1;const e=document.createElement("div");e.className="shaka-modal-ad-overlay";const n=document.createElement("div");n.className="shaka-modal-ad-content";const o=this.setOverlay(this.options),a=document.createElement("button");a.className="shaka-ad-play-button";const p=document.createElement("i");p.classList.add("material-icons-round"),p.textContent="play_arrow";const C=(y=(u=this.player.localization)==null?void 0:u.resolve("PLAY"))!=null?y:"Play",b=document.createTextNode(C);a.appendChild(p),a.appendChild(b),a.addEventListener("click",()=>{this.player.videoElement.play()}),n.appendChild(o),n.appendChild(a),e.appendChild(n),this.player.container.appendChild(e),this.player.on(["adComplete","adError","adSkip","pause","play","adStart"],E=>{switch(E){case"adComplete":case"adError":case"adSkip":case"play":this.isAdPlaying=!1;break;case"adStart":this.isAdPlaying=!0;break}if(this.isAdPlaying||this.player.controls.isSeeking()||!this.player.videoElement.paused)return e.classList.add("shaka-hidden");e.classList.remove("shaka-hidden")})})}setOverlay(e){switch(e.kind){case"image":const n=document.createElement("img");n.src=e.src;const o=document.createElement("a");return o.href=e.link,o.target="_blank",o.rel="sponsored",this.options.width&&(n.style.width=this.options.width+"px"),this.options.height&&(n.style.height=this.options.height+"px"),o.appendChild(n),o;case"iframe":const a=document.createElement("iframe");return a.src=e.src,this.options.width&&(a.style.width=this.options.width+"px"),this.options.height&&(a.style.height=this.options.height+"px"),a.scrolling="no",a;default:throw new m(this.name,i.ERROR,"Invalid ad overlay kind")}}}return c}();