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.

73 lines (72 loc) 2.57 kB
var m = Object.defineProperty; var y = (o, i, e) => i in o ? m(o, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[i] = e; var a = (o, i, e) => y(o, typeof i != "symbol" ? i + "" : i, e); var l = (o, i, e) => new Promise((r, p) => { var h = (t) => { try { s(e.next(t)); } catch (n) { p(n); } }, d = (t) => { try { s(e.throw(t)); } catch (n) { p(n); } }, s = (t) => t.done ? r(t.value) : Promise.resolve(t.value).then(h, d); s((e = e.apply(o, i)).next()); }); import U from "./Base.js"; import { i as k } from "../Common-B3lKdzU9.js"; import { P as u, S as w } 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 S extends U { constructor(e, r) { super(e); a(this, "name", "PopUpPlugin"); a(this, "options"); a(this, "clickCounter"); a(this, "alreadyShowPopUp"); this.clickCounter = 1, this.alreadyShowPopUp = !1, this.options = r; } setup() { return l(this, null, function* () { if (!this.options || !k(this.options)) throw new u(this.name, w.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 u(this.name, w.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(e) { var p; if (this.alreadyShowPopUp || e.type !== "touchend") return; const r = (p = this.options.clicks) != null ? p : 1; if (this.clickCounter >= r) { e.stopPropagation(); const { open: h, url: d, width: s, height: t, features: n } = this.options, c = []; if (h === "window") { const f = s != null ? s : screen.width, P = t != null ? t : screen.height; c.push(`width=${f}`), c.push(`height=${P}`), n && c.push(n); } window.open(d, "_blank", c.join(",")), this.alreadyShowPopUp = !0, this.player.emit("popUpOpened"); } this.clickCounter += 1; } } export { S as default };