@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.
package/index.d.ts CHANGED
@@ -149,6 +149,8 @@ export interface WaveformPlayerOptions {
149
149
  showHoverTime?: boolean;
150
150
  /** Show detected BPM. @default false */
151
151
  showBPM?: boolean;
152
+ /** Known BPM shown in the badge (with `showBPM`); wins over auto-detection. */
153
+ bpm?: number;
152
154
 
153
155
  // ── Behaviour ─────────────────────────────────────────────────
154
156
  /** Begin playback on load. @default false */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arraypress/waveform-player",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Lightweight, customizable audio player with waveform visualization",
5
5
  "type": "module",
6
6
  "types": "./index.d.ts",
@@ -55,9 +55,13 @@
55
55
  `buttonStyle: 'minimal'` / data-button-style="minimal". Ideal for sample-pack
56
56
  and beat-store preview grids. */
57
57
  .waveform-btn-minimal {
58
- width: auto;
59
- height: auto;
60
- min-width: 0;
58
+ /* A FIXED box is essential: toggling the play glyph (which is optically
59
+ nudged 1px) for the pause glyph would otherwise change the button's
60
+ auto width, shifting the adjacent waveform — and re-sampling its bars —
61
+ on every play/pause. Fixed width keeps the canvas (and bars) stable. */
62
+ width: 1.625rem;
63
+ height: 1.625rem;
64
+ min-width: 1.625rem;
61
65
  border: none;
62
66
  border-radius: 0;
63
67
  opacity: 0.7;
package/src/js/core.js CHANGED
@@ -326,6 +326,9 @@ export class WaveformPlayer {
326
326
 
327
327
  // Set canvas size
328
328
  this.resizeCanvas();
329
+
330
+ // Show a caller-supplied BPM immediately (no audio decode required).
331
+ this.updateBPMDisplay();
329
332
  }
330
333
 
331
334
  /**
@@ -1375,8 +1378,12 @@ export class WaveformPlayer {
1375
1378
  * @private
1376
1379
  */
1377
1380
  updateBPMDisplay() {
1378
- if (this.bpmEl && this.bpmValueEl && this.detectedBPM) {
1379
- this.bpmValueEl.textContent = Math.round(this.detectedBPM);
1381
+ // A caller-supplied `bpm` wins over auto-detection — useful when peaks
1382
+ // are pre-generated (so the audio is never decoded) but the BPM is known
1383
+ // anyway, e.g. sample-pack previews where the tempo is in the metadata.
1384
+ const bpm = this.options.bpm || this.detectedBPM;
1385
+ if (this.bpmEl && this.bpmValueEl && bpm) {
1386
+ this.bpmValueEl.textContent = Math.round(bpm);
1380
1387
  this.bpmEl.style.display = 'inline-flex';
1381
1388
  }
1382
1389
  }
package/src/js/themes.js CHANGED
@@ -209,6 +209,9 @@ export const DEFAULT_OPTIONS = {
209
209
  showTime: true,
210
210
  showHoverTime: false,
211
211
  showBPM: false,
212
+ // Known BPM to display in the badge (with showBPM). Wins over auto-detection
213
+ // — set it when peaks are pre-generated so the tempo still shows. null = auto.
214
+ bpm: null,
212
215
  singlePlay: true,
213
216
  playOnSeek: true,
214
217
  enableMediaSession: true,
package/src/js/utils.js CHANGED
@@ -164,6 +164,7 @@ export function parseDataAttributes(element) {
164
164
  setBool('showTime');
165
165
  setBool('showHoverTime');
166
166
  setBool('showBPM', 'showBpm');
167
+ setNum('bpm');
167
168
  setBool('singlePlay');
168
169
  setBool('playOnSeek');
169
170