@slashedcloud/player
Version:
A media player application utilizing Shaka Player for adaptive video streaming, capable of playing HLS, MPD and plain HTTP video streams.
74 lines (73 loc) • 2.33 kB
JavaScript
import '../Logo.css';var d = Object.defineProperty;
var g = (n, o, e) => o in n ? d(n, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[o] = e;
var l = (n, o, e) => g(n, typeof o != "symbol" ? o + "" : o, e);
var p = (n, o, e) => new Promise((s, t) => {
var i = (r) => {
try {
a(e.next(r));
} catch (c) {
t(c);
}
}, m = (r) => {
try {
a(e.throw(r));
} catch (c) {
t(c);
}
}, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(i, m);
a((e = e.apply(n, o)).next());
});
import h from "./Base.js";
import { P as f, S as E } from "../PlayerError-JebC7rsX.js";
import { s as u } from "../shaka-player.ui-CvkRFlcE.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 P extends u.ui.Element {
constructor(o, e, s) {
super(o, e);
const t = document.createElement("img");
if (t.src = s.src, t.alt = "Logo", t.className = "logo", s.link) {
const i = document.createElement("a");
i.href = s.link, i.target = "_blank", i.rel = "sponsored", i.appendChild(t), o.appendChild(i);
} else o.appendChild(t);
}
}
class y {
constructor(o) {
l(this, "options");
this.options = o;
}
create(o, e) {
return new P(o, e, this.options);
}
}
class L extends h {
/**
* Creates an instance of LogoFeature.
* @param {Player} player - The player instance.
*/
constructor(e, s) {
super(e);
l(this, "name", "LogoPlugin");
l(this, "options");
this.options = s;
}
/**
* Sets up the LogoFeature by registering the logo element to the control panel
* and updating the player configuration.
* @throws {Error} If the image option is not provided.
*/
setup() {
return p(this, null, function* () {
if (!this.options.src) throw new f(this.name, E.ERROR, "Source is not provided");
if (window.innerWidth < 768 || !this.player.uiConfig.controlPanelElements) return;
u.ui.Controls.registerElement("logo", new y(this.options)), this.player.uiConfig.controlPanelElements.indexOf("logo") === -1 && this.player.uiConfig.controlPanelElements.push("logo");
});
}
}
export {
L as default
};