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.

77 lines (76 loc) 2.89 kB
import '../Download.css';var f = Object.defineProperty; var L = (o, t, e) => t in o ? f(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e; var u = (o, t, e) => L(o, typeof t != "symbol" ? t + "" : t, e); var C = (o, t, e) => new Promise((a, s) => { var d = (n) => { try { i(e.next(n)); } catch (l) { s(l); } }, c = (n) => { try { i(e.throw(n)); } catch (l) { s(l); } }, i = (n) => n.done ? a(n.value) : Promise.resolve(n.value).then(d, c); i((e = e.apply(o, t)).next()); }); import x from "./Base.js"; import { P, S as T } from "../PlayerError-JebC7rsX.js"; /*! * 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) */ class z extends x { /** * Creates an instance of DownloadFeature. * @param player - The SlashedCloudPlayer instance. */ constructor(e, a) { super(e); u(this, "name", "DownloadPlugin"); u(this, "options"); this.options = a; } /** * Sets up the DownloadFeature by creating the download container, button, list, and items. */ setup() { return C(this, null, function* () { var i, n, l, h; if (!this.options || !Array.isArray(this.options)) throw new P(this.name, T.ERROR, "The options are missing or not clearly defined.", { description: "Provide the necessary options to complete the setup process." }); const e = document.createElement("div"); e.classList.add("download-container"); const a = document.createElement("button"); a.classList.add("download-button"); const s = document.createElement("span"); s.classList.add("material-icons-round"), s.innerText = "cloud_download", a.appendChild(s), e.appendChild(a); const d = document.createElement("ul"); d.classList.add("download-list"), e.appendChild(d); const c = document.createElement("li"); c.classList.add("download-title"), c.innerText = (n = (i = this.player.localization) == null ? void 0 : i.resolve("QUALITY")) != null ? n : "Quality", d.appendChild(c); for (const w in this.options) { const p = this.options[w]; if (!p.url) continue; const m = document.createElement("li"); m.classList.add("download-item"); const r = document.createElement("a"); r.href = p.url, r.target = "_blank"; const E = document.createElement("span"); E.innerText = (l = p.label) != null ? l : `Download ${w}`, r.appendChild(E); const y = document.createElement("span"); y.innerText = (h = p.size) != null ? h : "", r.appendChild(y), m.appendChild(r), d.appendChild(m); } this.player.container.appendChild(e); }); } } export { z as default };