@slashedcloud/player
Version:
A media player application utilizing Shaka Player for adaptive video streaming, capable of playing HLS, MPD and plain HTTP video streams.
72 lines (71 loc) • 2.15 kB
JavaScript
var h = Object.defineProperty;
var m = (o, s, e) => s in o ? h(o, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[s] = e;
var p = (o, s, e) => m(o, typeof s != "symbol" ? s + "" : s, e);
var l = (o, s, e) => new Promise((t, n) => {
var c = (i) => {
try {
r(e.next(i));
} catch (a) {
n(a);
}
}, g = (i) => {
try {
r(e.throw(i));
} catch (a) {
n(a);
}
}, r = (i) => i.done ? t(i.value) : Promise.resolve(i.value).then(c, g);
r((e = e.apply(o, s)).next());
});
import u from "./Base.js";
import { i as d } from "../Common-B3lKdzU9.js";
import { P as y, S as P } 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 b extends u {
/**
* Creates an instance of PixelTagFeature.
* @param {Player} player - The player instance.
*/
constructor(e, t) {
super(e);
p(this, "name", "PixelTagPlugin");
p(this, "options");
this.options = t;
}
/**
* Sets up the PixelTagFeature.
* Adds event listeners for pixel tag events.
* @throws {Error} If events are not defined.
*/
setup() {
return l(this, null, function* () {
if (!this.options || !d(this.options))
throw new y(this.name, P.ERROR, "The options are missing or not clearly defined.", {
description: "Provide the necessary options to complete the setup process."
});
const e = Object.keys(this.options);
this.player.on(e, (t) => {
const n = this.options[t];
this.sendEvent(t, n);
});
});
}
/**
* Sends an event to analytics.
* @param {string} name - The name of the event.
* @param {string} pixelTagUrl - The URL of the pixel tag.
*/
sendEvent(e, t) {
return l(this, null, function* () {
var n = new Image();
n.src = t, this.player.options.debug && (console.log("======= Pixel Tag Event debug ======="), console.log("Event sent:", e));
});
}
}
export {
b as default
};