@arraypress/waveform-player 1.11.0 → 1.12.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.
@@ -104,6 +104,7 @@ function parseDataAttributes(element) {
104
104
  setBool("showTime");
105
105
  setBool("showHoverTime");
106
106
  setBool("showBPM", "showBpm");
107
+ setNum("bpm");
107
108
  setBool("singlePlay");
108
109
  setBool("playOnSeek");
109
110
  if (element.dataset.title) options.title = element.dataset.title;
@@ -734,6 +735,9 @@ var DEFAULT_OPTIONS = {
734
735
  showTime: true,
735
736
  showHoverTime: false,
736
737
  showBPM: false,
738
+ // Known BPM to display in the badge (with showBPM). Wins over auto-detection
739
+ // — set it when peaks are pre-generated so the tempo still shows. null = auto.
740
+ bpm: null,
737
741
  singlePlay: true,
738
742
  playOnSeek: true,
739
743
  enableMediaSession: true,
@@ -1018,6 +1022,7 @@ var WaveformPlayer = class _WaveformPlayer {
1018
1022
  this.speedBtn = this.container.querySelector(".speed-btn");
1019
1023
  this.speedMenu = this.container.querySelector(".speed-menu");
1020
1024
  this.resizeCanvas();
1025
+ this.updateBPMDisplay();
1021
1026
  }
1022
1027
  /**
1023
1028
  * Create audio element
@@ -1823,8 +1828,9 @@ var WaveformPlayer = class _WaveformPlayer {
1823
1828
  * @private
1824
1829
  */
1825
1830
  updateBPMDisplay() {
1826
- if (this.bpmEl && this.bpmValueEl && this.detectedBPM) {
1827
- this.bpmValueEl.textContent = Math.round(this.detectedBPM);
1831
+ const bpm = this.options.bpm || this.detectedBPM;
1832
+ if (this.bpmEl && this.bpmValueEl && bpm) {
1833
+ this.bpmValueEl.textContent = Math.round(bpm);
1828
1834
  this.bpmEl.style.display = "inline-flex";
1829
1835
  }
1830
1836
  }