@scarlett-player/embed 1.4.0 → 1.5.0

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.
@@ -6619,7 +6619,6 @@ function createCaptionsPlugin(config = {}) {
6619
6619
  let api = null;
6620
6620
  let video = null;
6621
6621
  let addedTrackElements = [];
6622
- let hlsTrackElements = [];
6623
6622
  let hlsSubtitleHandler = null;
6624
6623
  let observedTextTracks = null;
6625
6624
  let hlsRetryTimer = null;
@@ -6638,18 +6637,10 @@ function createCaptionsPlugin(config = {}) {
6638
6637
  trackEl.parentNode?.removeChild(trackEl);
6639
6638
  }
6640
6639
  addedTrackElements = [];
6641
- hlsTrackElements = [];
6642
6640
  api?.setState("textTracks", []);
6643
6641
  api?.setState("currentTextTrack", null);
6644
6642
  };
6645
- const removeHlsTrackElements = () => {
6646
- for (const trackEl of hlsTrackElements) {
6647
- trackEl.parentNode?.removeChild(trackEl);
6648
- addedTrackElements = addedTrackElements.filter((el) => el !== trackEl);
6649
- }
6650
- hlsTrackElements = [];
6651
- };
6652
- const addTrackElement = (source, origin = "config") => {
6643
+ const addTrackElement = (source) => {
6653
6644
  const videoEl = getVideo2();
6654
6645
  if (!videoEl) throw new Error("No video element");
6655
6646
  const trackEl = document.createElement("track");
@@ -6660,9 +6651,6 @@ function createCaptionsPlugin(config = {}) {
6660
6651
  trackEl.default = false;
6661
6652
  videoEl.appendChild(trackEl);
6662
6653
  addedTrackElements.push(trackEl);
6663
- if (origin === "hls") {
6664
- hlsTrackElements.push(trackEl);
6665
- }
6666
6654
  if (trackEl.track) {
6667
6655
  trackEl.track.mode = "disabled";
6668
6656
  }
@@ -6750,21 +6738,9 @@ function createCaptionsPlugin(config = {}) {
6750
6738
  if (!hlsPlugin || hlsPlugin.isNativeHLS()) return;
6751
6739
  const hlsInstance = hlsPlugin.getHlsInstance();
6752
6740
  if (!hlsInstance?.subtitleTracks?.length) return;
6753
- api.logger.debug("Extracting HLS subtitle tracks", {
6741
+ api.logger.debug("Syncing HLS subtitle tracks", {
6754
6742
  count: hlsInstance.subtitleTracks.length
6755
6743
  });
6756
- removeHlsTrackElements();
6757
- for (const hlsTrack of hlsInstance.subtitleTracks) {
6758
- addTrackElement(
6759
- {
6760
- language: hlsTrack.lang || "unknown",
6761
- label: hlsTrack.name || `Subtitle ${hlsTrack.id}`,
6762
- src: hlsTrack.url,
6763
- kind: "subtitles"
6764
- },
6765
- "hls"
6766
- );
6767
- }
6768
6744
  syncTracksToState();
6769
6745
  maybeAutoSelect();
6770
6746
  };
@@ -6801,7 +6777,7 @@ function createCaptionsPlugin(config = {}) {
6801
6777
  const initSources = () => {
6802
6778
  if (!config.sources?.length) return;
6803
6779
  for (const source of config.sources) {
6804
- addTrackElement(source, "config");
6780
+ addTrackElement(source);
6805
6781
  }
6806
6782
  };
6807
6783
  return {