@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/dist/waveform-player.cjs +8 -2
- package/dist/waveform-player.cjs.map +2 -2
- package/dist/waveform-player.css +1 -1
- package/dist/waveform-player.esm.js +3 -3
- package/dist/waveform-player.esm.js.map +3 -3
- package/dist/waveform-player.js +8 -2
- package/dist/waveform-player.min.js +3 -3
- package/dist/waveform-player.min.js.map +3 -3
- package/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/css/waveform-player.css +7 -3
- package/src/js/core.js +9 -2
- package/src/js/themes.js +3 -0
- package/src/js/utils.js +1 -0
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
|
@@ -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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
1379
|
-
|
|
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,
|