@v360-tech/v360-player 1.2.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -163,8 +163,8 @@ const e = {
163
163
  "speed-1.00": `<img src="${Y}" width="24" height="24" alt="1x speed">`,
164
164
  "speed-1.50": `<img src="${R}" width="24" height="24" alt="1.5x speed">`,
165
165
  "speed-2.00": `<img src="${N}" width="24" height="24" alt="2x speed">`
166
- };
167
- class j extends HTMLElement {
166
+ }, j = "X-Jewel-Store", D = "69d2c1660df6540944e25eb708fb252724ab27fb";
167
+ class z extends HTMLElement {
168
168
  progressBarStyle = e.None;
169
169
  _hls;
170
170
  _videoPlayer;
@@ -219,20 +219,20 @@ class j extends HTMLElement {
219
219
  if (!A || !g) return;
220
220
  const I = () => {
221
221
  if (!this._videoPlayer) return;
222
- const i = this._videoPlayer.currentTime / this._videoPlayer.duration * 100;
223
- if (g.style.width = `${i}%`, this.progressBarStyle === e.Segments) {
224
- const t = this.shadowRoot?.querySelectorAll(".progress-segment");
225
- t && t.forEach((C, o) => {
226
- const n = (o + 1) * (100 / t.length);
227
- i >= n ? C.classList.add("filled") : C.classList.remove("filled");
222
+ const t = this._videoPlayer.currentTime / this._videoPlayer.duration * 100;
223
+ if (g.style.width = `${t}%`, this.progressBarStyle === e.Segments) {
224
+ const o = this.shadowRoot?.querySelectorAll(".progress-segment");
225
+ o && o.forEach((i, C) => {
226
+ const c = (C + 1) * (100 / o.length);
227
+ t >= c ? i.classList.add("filled") : i.classList.remove("filled");
228
228
  });
229
229
  }
230
230
  };
231
231
  this._videoPlayer.addEventListener("timeupdate", I);
232
- const s = (i) => {
233
- if (!this._videoPlayer || !(i instanceof MouseEvent)) return;
234
- const t = A.getBoundingClientRect(), C = Math.max(0, Math.min(1, (i.clientX - t.left) / t.width));
235
- this._videoPlayer.currentTime = C * this._videoPlayer.duration;
232
+ const s = (t) => {
233
+ if (!this._videoPlayer || !(t instanceof MouseEvent)) return;
234
+ const o = A.getBoundingClientRect(), i = Math.max(0, Math.min(1, (t.clientX - o.left) / o.width));
235
+ this._videoPlayer.currentTime = i * this._videoPlayer.duration;
236
236
  };
237
237
  A.addEventListener("click", s);
238
238
  }
@@ -469,13 +469,13 @@ class j extends HTMLElement {
469
469
  async initializeHls(A, g) {
470
470
  return new Promise((I, s) => {
471
471
  try {
472
- const i = {
473
- debug: !0,
472
+ const o = {
473
+ // debug: true,
474
474
  enableWorker: !0,
475
475
  lowLatencyMode: !0,
476
476
  backBufferLength: 90,
477
- startLevel: -1,
478
- autoStartLoad: !0,
477
+ startLevel: parseInt(this.getAttribute("default-quality") || "-1"),
478
+ autoStartLoad: this.hasAttribute("auto-play"),
479
479
  manifestLoadingTimeOut: 2e4,
480
480
  manifestLoadingMaxRetry: 3,
481
481
  manifestLoadingRetryDelay: 500,
@@ -485,11 +485,11 @@ class j extends HTMLElement {
485
485
  fragLoadingTimeOut: 2e4,
486
486
  fragLoadingMaxRetry: 3,
487
487
  fragLoadingRetryDelay: 500,
488
- xhrSetup: (t) => {
489
- t.withCredentials = !1;
488
+ xhrSetup: (i) => {
489
+ i.withCredentials = !1, i.setRequestHeader(j, D);
490
490
  }
491
491
  };
492
- this._hls = new l(i), this._hls.on(l.Events.ERROR, (t, C) => {
492
+ this._hls = new l(o), this._hls.on(l.Events.ERROR, (i, C) => {
493
493
  if (console.error("HLS Error:", C), C.fatal)
494
494
  switch (C.type) {
495
495
  case l.ErrorTypes.NETWORK_ERROR:
@@ -504,26 +504,26 @@ class j extends HTMLElement {
504
504
  }
505
505
  }), this._hls.on(l.Events.MEDIA_ATTACHED, () => {
506
506
  console.log("Media attached, loading source:", g), this._hls?.loadSource(g);
507
- }), this._hls.on(l.Events.MANIFEST_PARSED, (t, C) => {
508
- console.log("Manifest parsed, levels:", C.levels), this.startListeners(), I(), this.hasAttribute("auto-play") && (console.log("Attempting autoplay..."), A.play().then(() => console.log("Playback started successfully")).catch(async (o) => {
509
- console.error("Autoplay failed:", o), A.muted = !0;
507
+ }), this._hls.on(l.Events.MANIFEST_PARSED, (i, C) => {
508
+ console.log("Manifest parsed, levels:", C.levels), this.startListeners(), I(), this.hasAttribute("auto-play") && (console.log("Attempting autoplay..."), A.play().then(() => console.log("Playback started successfully")).catch(async (c) => {
509
+ console.error("Autoplay failed:", c), A.muted = !0;
510
510
  try {
511
511
  await A.play(), console.log("Muted autoplay successful");
512
- } catch (n) {
513
- console.error("Muted autoplay also failed:", n);
512
+ } catch (d) {
513
+ console.error("Muted autoplay also failed:", d);
514
514
  }
515
515
  }));
516
516
  }), console.log("Attaching media element..."), this._hls.attachMedia(A);
517
- } catch (i) {
518
- console.error("Error in HLS initialization:", i), s(i);
517
+ } catch (t) {
518
+ console.error("Error in HLS initialization:", t), s(t);
519
519
  }
520
520
  });
521
521
  }
522
522
  startListeners() {
523
523
  if (!this.shadowRoot) return;
524
- const A = a(this.shadowRoot).find(".play"), g = a(this.shadowRoot).find(".pause"), I = a(this.shadowRoot).find(".forward"), s = a(this.shadowRoot).find(".backward"), i = a(this.shadowRoot).find(".fullscreen");
525
- if (A.on("click", () => this.play()), g.on("click", () => this.pause()), I.on("click", () => this.forward()), s.on("click", () => this.backward()), i.on("click", () => this.toggleFullscreen()), this._videoPlayer) {
526
- const t = a(this.shadowRoot).find(".duration"), C = a(this.shadowRoot).find(".progress-bar"), o = a(this.shadowRoot).find(".speed-container");
524
+ const A = a(this.shadowRoot).find(".play"), g = a(this.shadowRoot).find(".pause"), I = a(this.shadowRoot).find(".forward"), s = a(this.shadowRoot).find(".backward"), t = a(this.shadowRoot).find(".fullscreen");
525
+ if (A.on("click", () => this.play()), g.on("click", () => this.pause()), I.on("click", () => this.forward()), s.on("click", () => this.backward()), t.on("click", () => this.toggleFullscreen()), this._videoPlayer) {
526
+ const o = a(this.shadowRoot).find(".duration"), i = a(this.shadowRoot).find(".progress-bar"), C = a(this.shadowRoot).find(".speed-container");
527
527
  this._videoPlayer.addEventListener("play", () => {
528
528
  A.hide(), g.show();
529
529
  }), this._videoPlayer.addEventListener("pause", () => {
@@ -532,30 +532,30 @@ class j extends HTMLElement {
532
532
  if (!this._videoPlayer || !this.shadowRoot) return;
533
533
  const r = this._videoPlayer.currentTime, m = this._videoPlayer.duration, u = r / m * 100;
534
534
  if (this.hasAttribute("show-time-display")) {
535
- const h = this.shadowRoot.querySelector(".current-time");
536
- h && (h.textContent = this.formatTime(r));
535
+ const p = this.shadowRoot.querySelector(".current-time");
536
+ p && (p.textContent = this.formatTime(r));
537
537
  }
538
538
  const b = this.shadowRoot.querySelector(".progress-bar-fill");
539
539
  if (b instanceof HTMLElement && (b.style.width = `${u}%`), this.progressBarStyle === e.Segments) {
540
- const h = this.shadowRoot.querySelectorAll(".progress-segment");
541
- h.forEach((M, w) => {
542
- const y = (w + 1) * (100 / h.length);
540
+ const p = this.shadowRoot.querySelectorAll(".progress-segment");
541
+ p.forEach((M, w) => {
542
+ const y = (w + 1) * (100 / p.length);
543
543
  u >= y ? M.classList.add("filled") : M.classList.remove("filled");
544
544
  });
545
545
  }
546
546
  }), this._videoPlayer.addEventListener("loadedmetadata", () => {
547
- this.hasAttribute("show-time-display") && t.text(this.formatTime(this._videoPlayer.duration));
548
- }), C.on("click", (r) => {
547
+ this.hasAttribute("show-time-display") && o.text(this.formatTime(this._videoPlayer.duration));
548
+ }), i.on("click", (r) => {
549
549
  const m = r.currentTarget.getBoundingClientRect(), u = (r.clientX - m.left) / m.width;
550
550
  this._videoPlayer.currentTime = u * this._videoPlayer.duration;
551
551
  });
552
- const n = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 2], p = this.getAttribute("playback-speeds")?.split(",").map(Number) || n, d = parseFloat(this.getAttribute("default-speed") || "1");
553
- let c = p.indexOf(d);
554
- c === -1 && (c = p.indexOf(1) || 0), d && !isNaN(d) && (this._videoPlayer.playbackRate = d, o.text(`${d}x`)), this.hasAttribute("show-speed-control") ? (o.show(), o.html(this.getSpeedIcon(d)), o.on("click", () => {
555
- c = (c + 1) % p.length;
556
- const r = p[c];
557
- this._videoPlayer.playbackRate = r, o.html(this.getSpeedIcon(r));
558
- })) : o.hide();
552
+ const c = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 2], d = this.getAttribute("playback-speeds")?.split(",").map(Number) || c, n = parseFloat(this.getAttribute("default-speed") || "1");
553
+ let h = d.indexOf(n);
554
+ h === -1 && (h = d.indexOf(1) || 0), n && !isNaN(n) && (this._videoPlayer.playbackRate = n, C.text(`${n}x`)), this.hasAttribute("show-speed-control") ? (C.show(), C.html(this.getSpeedIcon(n)), C.on("click", () => {
555
+ h = (h + 1) % d.length;
556
+ const r = d[h];
557
+ this._videoPlayer.playbackRate = r, C.html(this.getSpeedIcon(r));
558
+ })) : C.hide();
559
559
  }
560
560
  }
561
561
  play() {
@@ -593,7 +593,7 @@ class j extends HTMLElement {
593
593
  this._hls && this._hls.destroy();
594
594
  }
595
595
  }
596
- customElements.define("v360-player", j);
596
+ customElements.define("v360-player", z);
597
597
  export {
598
- j as V360Player
598
+ z as V360Player
599
599
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v360-tech/v360-player",
3
- "version": "1.2.1",
3
+ "version": "1.4.1",
4
4
  "description": "A lightweight, customizable HLS video player web component with built-in controls",
5
5
  "type": "module",
6
6
  "main": "dist/v360-player.browser.js",