@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.3 kB
JavaScript
var N=Object.defineProperty;var k=e=>{throw TypeError(e)};var O=(e,o,n)=>o in e?N(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n;var i=(e,o,n)=>O(e,typeof o!="symbol"?o+"":o,n),P=(e,o,n)=>o.has(e)||k("Cannot "+n);var x=(e,o,n)=>o.has(e)?k("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(e):o.set(e,n);var I=(e,o,n)=>(P(e,o,"access private method"),n);var A=(e,o,n)=>new Promise((p,u)=>{var c=d=>{try{t(n.next(d))}catch(r){u(r)}},T=d=>{try{t(n.throw(d))}catch(r){u(r)}},t=d=>d.done?p(d.value):Promise.resolve(d.value).then(c,T);t((n=n.apply(e,o)).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.Download=function(){"use strict";var c,L;var e=document.createElement("style");e.textContent=`.download-container{position:absolute;top:.3125rem;right:.3125rem;z-index:100;display:flex;flex-direction:column;align-items:flex-end}.download-container:hover .download-button{border-bottom-right-radius:0;border-bottom-left-radius:0}.download-container .download-button{padding:.1875rem .4375rem 0rem;border-radius:.25rem;background-color:#000000b3;color:var(--shaka-player-color);font-size:.9rem;cursor:pointer;border:none}.download-container .download-button span{color:var(--shaka-player-icon-color)}.download-container .download-button:hover+.download-list{display:block}.download-container .download-button:hover{border-bottom-right-radius:0;border-bottom-left-radius:0}.download-container .download-button:hover span{color:var(--shaka-player-icon-hover-color)}.download-container .download-button:hover+.download-list{border-top-right-radius:0;display:block}.download-container .download-item{padding:.1875rem .625rem;cursor:pointer}.download-container .download-item span:first-child{margin-right:.9375rem}.download-container .download-item a{display:flex;justify-content:space-between;color:var(--shaka-player-color);text-decoration:none}.download-container .download-item:hover a{color:var(--shaka-player-hover-color)}.download-container .download-list{padding:.3125rem 0;display:none;border-radius:.25rem;background-color:#000000b3;color:var(--shaka-player-icon-hover-color);font-size:.8125rem;list-style:none;margin:0}.download-container .download-list:hover{border-top-right-radius:0;display:block}.download-container .download-list .download-title{padding:.3125rem .625rem;font-weight:700}
`,document.head.appendChild(e);class o{constructor(d){i(this,"player");this.player=d}}var n=(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))(n||{});class p extends Error{constructor(r,s,l,a){super(l);x(this,c);i(this,"name");i(this,"message");i(this,"severity");i(this,"code");i(this,"description");i(this,"reason");this.name=r,this.message=l,this.severity=s,this.code=a==null?void 0:a.code,this.description=a==null?void 0:a.description,this.reason=a==null?void 0:a.reason,I(this,c,L).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}}}c=new WeakSet,L=function(){var s,l,a;let r=`${this.severityString}: ${this.name} | ${this.message}`;switch(this.description&&(r+=` | ${this.description}`),this.code&&(r+=` [${this.code}]`),this.severity){case 0:console.info(r,(s=this.reason)!=null?s:"");break;case 1:console.warn(r,(l=this.reason)!=null?l:"");break;case 2:case 3:case 4:default:console.error(r,(a=this.reason)!=null?a:"");break}};class u extends o{constructor(r,s){super(r);i(this,"name","DownloadPlugin");i(this,"options");this.options=s}setup(){return A(this,null,function*(){var g,y,f,v;if(!this.options||!Array.isArray(this.options))throw new p(this.name,n.ERROR,"The options are missing or not clearly defined.",{description:"Provide the necessary options to complete the setup process."});const r=document.createElement("div");r.classList.add("download-container");const s=document.createElement("button");s.classList.add("download-button");const l=document.createElement("span");l.classList.add("material-icons-round"),l.innerText="cloud_download",s.appendChild(l),r.appendChild(s);const a=document.createElement("ul");a.classList.add("download-list"),r.appendChild(a);const w=document.createElement("li");w.classList.add("download-title"),w.innerText=(y=(g=this.player.localization)==null?void 0:g.resolve("QUALITY"))!=null?y:"Quality",a.appendChild(w);for(const C in this.options){const m=this.options[C];if(!m.url)continue;const b=document.createElement("li");b.classList.add("download-item");const h=document.createElement("a");h.href=m.url,h.target="_blank";const R=document.createElement("span");R.innerText=(f=m.label)!=null?f:`Download ${C}`,h.appendChild(R);const E=document.createElement("span");E.innerText=(v=m.size)!=null?v:"",h.appendChild(E),b.appendChild(h),a.appendChild(b)}this.player.container.appendChild(r)})}}return u}();