@scarlett-player/embed 1.4.0 → 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.
package/README.md CHANGED
@@ -107,6 +107,7 @@ The simplest way to embed a player. Just add the script and use data attributes:
107
107
  | `data-loop` | boolean | `false` | Loop playback |
108
108
  | `data-playback-rate` | number | `1.0` | Playback speed |
109
109
  | `data-start-time` | number | `0` | Start position (seconds) |
110
+ | `data-share-url` | string | - | Canonical page URL for the share plugin. Set this on iframe embeds, or sharing links to the player page instead of yours |
110
111
  | `data-class` | string | - | Custom CSS class(es) |
111
112
 
112
113
  #### Audio-specific Attributes
package/dist/embed.js CHANGED
@@ -8572,7 +8572,6 @@ function createCaptionsPlugin(config = {}) {
8572
8572
  let api = null;
8573
8573
  let video = null;
8574
8574
  let addedTrackElements = [];
8575
- let hlsTrackElements = [];
8576
8575
  let hlsSubtitleHandler = null;
8577
8576
  let observedTextTracks = null;
8578
8577
  let hlsRetryTimer = null;
@@ -8591,18 +8590,10 @@ function createCaptionsPlugin(config = {}) {
8591
8590
  trackEl.parentNode?.removeChild(trackEl);
8592
8591
  }
8593
8592
  addedTrackElements = [];
8594
- hlsTrackElements = [];
8595
8593
  api?.setState("textTracks", []);
8596
8594
  api?.setState("currentTextTrack", null);
8597
8595
  };
8598
- const removeHlsTrackElements = () => {
8599
- for (const trackEl of hlsTrackElements) {
8600
- trackEl.parentNode?.removeChild(trackEl);
8601
- addedTrackElements = addedTrackElements.filter((el) => el !== trackEl);
8602
- }
8603
- hlsTrackElements = [];
8604
- };
8605
- const addTrackElement = (source, origin = "config") => {
8596
+ const addTrackElement = (source) => {
8606
8597
  const videoEl = getVideo2();
8607
8598
  if (!videoEl) throw new Error("No video element");
8608
8599
  const trackEl = document.createElement("track");
@@ -8613,9 +8604,6 @@ function createCaptionsPlugin(config = {}) {
8613
8604
  trackEl.default = false;
8614
8605
  videoEl.appendChild(trackEl);
8615
8606
  addedTrackElements.push(trackEl);
8616
- if (origin === "hls") {
8617
- hlsTrackElements.push(trackEl);
8618
- }
8619
8607
  if (trackEl.track) {
8620
8608
  trackEl.track.mode = "disabled";
8621
8609
  }
@@ -8703,21 +8691,9 @@ function createCaptionsPlugin(config = {}) {
8703
8691
  if (!hlsPlugin || hlsPlugin.isNativeHLS()) return;
8704
8692
  const hlsInstance = hlsPlugin.getHlsInstance();
8705
8693
  if (!hlsInstance?.subtitleTracks?.length) return;
8706
- api.logger.debug("Extracting HLS subtitle tracks", {
8694
+ api.logger.debug("Syncing HLS subtitle tracks", {
8707
8695
  count: hlsInstance.subtitleTracks.length
8708
8696
  });
8709
- removeHlsTrackElements();
8710
- for (const hlsTrack of hlsInstance.subtitleTracks) {
8711
- addTrackElement(
8712
- {
8713
- language: hlsTrack.lang || "unknown",
8714
- label: hlsTrack.name || `Subtitle ${hlsTrack.id}`,
8715
- src: hlsTrack.url,
8716
- kind: "subtitles"
8717
- },
8718
- "hls"
8719
- );
8720
- }
8721
8697
  syncTracksToState();
8722
8698
  maybeAutoSelect();
8723
8699
  };
@@ -8754,7 +8730,7 @@ function createCaptionsPlugin(config = {}) {
8754
8730
  const initSources = () => {
8755
8731
  if (!config.sources?.length) return;
8756
8732
  for (const source of config.sources) {
8757
- addTrackElement(source, "config");
8733
+ addTrackElement(source);
8758
8734
  }
8759
8735
  };
8760
8736
  return {