@arraypress/waveform-player 1.22.0 → 1.23.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.
@@ -94,6 +94,9 @@ function parseDataAttributes(element) {
94
94
  if (element.dataset.preload) {
95
95
  options.preload = element.dataset.preload;
96
96
  }
97
+ if (element.dataset.crossOrigin) {
98
+ options.crossOrigin = element.dataset.crossOrigin;
99
+ }
97
100
  if (element.dataset.audioMode) options.audioMode = element.dataset.audioMode;
98
101
  if (element.dataset.style) options.waveformStyle = element.dataset.style;
99
102
  if (element.dataset.waveformStyle) options.waveformStyle = element.dataset.waveformStyle;
@@ -702,6 +705,15 @@ var DEFAULT_OPTIONS = {
702
705
  // every-frame scan means a higher value costs no extra extraction time.
703
706
  samples: DEFAULT_SAMPLES,
704
707
  preload: "metadata",
708
+ // CORS mode for the underlying <audio> element. Left null by default so the
709
+ // player behaves like a plain <audio> and never forces a CORS request —
710
+ // setting 'anonymous' here would break playback of media hosted on origins
711
+ // that don't send Access-Control-Allow-Origin (default-config S3/CDN). The
712
+ // playback element is never fed to createMediaElementSource, so it never
713
+ // needs CORS-clean media; peak analysis uses a separate fetch() path with
714
+ // its own placeholder fallback. Set 'anonymous' / 'use-credentials' only if
715
+ // you specifically need it. See issue #18.
716
+ crossOrigin: null,
705
717
  // Audio mode — 'self' = player owns the <audio> element (default, current
706
718
  // behavior). 'external' = player is a visualization-only surface; no audio
707
719
  // element is created, play() dispatches `waveformplayer:request-play`
@@ -1262,7 +1274,9 @@ var WaveformPlayer = class _WaveformPlayer {
1262
1274
  }
1263
1275
  this.audio = new Audio();
1264
1276
  this.audio.preload = this.options.preload || "metadata";
1265
- this.audio.crossOrigin = "anonymous";
1277
+ if (this.options.crossOrigin) {
1278
+ this.audio.crossOrigin = this.options.crossOrigin;
1279
+ }
1266
1280
  }
1267
1281
  // ============================================
1268
1282
  // Feature Initialization
@@ -1836,6 +1850,9 @@ var WaveformPlayer = class _WaveformPlayer {
1836
1850
  if (options.preload && this.audio) {
1837
1851
  this.audio.preload = options.preload;
1838
1852
  }
1853
+ if (options.crossOrigin && this.audio) {
1854
+ this.audio.crossOrigin = options.crossOrigin;
1855
+ }
1839
1856
  if (artist !== null) {
1840
1857
  this.syncArtist(artist);
1841
1858
  }