@arraypress/waveform-player 1.10.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 +22 -8
- 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 +22 -8
- package/dist/waveform-player.min.js +3 -3
- package/dist/waveform-player.min.js.map +3 -3
- package/index.d.ts +8 -0
- package/package.json +1 -1
- package/src/css/waveform-player.css +26 -0
- package/src/js/core.js +10 -3
- package/src/js/themes.js +15 -5
- package/src/js/utils.js +2 -0
package/dist/waveform-player.cjs
CHANGED
|
@@ -86,6 +86,7 @@ function parseDataAttributes(element) {
|
|
|
86
86
|
setNum("barRadius");
|
|
87
87
|
if (element.dataset.buttonAlign) options.buttonAlign = element.dataset.buttonAlign;
|
|
88
88
|
if (element.dataset.layout) options.layout = element.dataset.layout;
|
|
89
|
+
if (element.dataset.buttonStyle) options.buttonStyle = element.dataset.buttonStyle;
|
|
89
90
|
if (element.dataset.colorPreset) options.colorPreset = element.dataset.colorPreset;
|
|
90
91
|
if (element.dataset.waveformColor) options.waveformColor = parseColorValue(element.dataset.waveformColor);
|
|
91
92
|
if (element.dataset.progressColor) options.progressColor = parseColorValue(element.dataset.progressColor);
|
|
@@ -103,6 +104,7 @@ function parseDataAttributes(element) {
|
|
|
103
104
|
setBool("showTime");
|
|
104
105
|
setBool("showHoverTime");
|
|
105
106
|
setBool("showBPM", "showBpm");
|
|
107
|
+
setNum("bpm");
|
|
106
108
|
setBool("singlePlay");
|
|
107
109
|
setBool("playOnSeek");
|
|
108
110
|
if (element.dataset.title) options.title = element.dataset.title;
|
|
@@ -682,8 +684,11 @@ function getColorPreset(presetName) {
|
|
|
682
684
|
var DEFAULT_OPTIONS = {
|
|
683
685
|
// Core settings
|
|
684
686
|
url: "",
|
|
685
|
-
height:
|
|
686
|
-
|
|
687
|
+
height: 64,
|
|
688
|
+
// Source peak resolution. The drawer resamples these to fit
|
|
689
|
+
// canvasWidth / (barWidth + barSpacing) bars, so this is fidelity headroom,
|
|
690
|
+
// not the visible bar count.
|
|
691
|
+
samples: 256,
|
|
687
692
|
preload: "metadata",
|
|
688
693
|
// Audio mode — 'self' = player owns the <audio> element (default, current
|
|
689
694
|
// behavior). 'external' = player is a visualization-only surface; no audio
|
|
@@ -702,12 +707,16 @@ var DEFAULT_OPTIONS = {
|
|
|
702
707
|
// waveform and the meta row (time / speed / BPM) is trimmed — ideal for
|
|
703
708
|
// sample-pack sample previews and dense grids.
|
|
704
709
|
layout: "default",
|
|
710
|
+
// Play/pause button style. 'circle' = bordered circle (default).
|
|
711
|
+
// 'minimal' = a bare play/pause glyph with no circle — the look sample-pack
|
|
712
|
+
// and beat stores use in their preview grids.
|
|
713
|
+
buttonStyle: "circle",
|
|
705
714
|
// Default waveform style
|
|
706
715
|
waveformStyle: "mirror",
|
|
707
716
|
barWidth: 2,
|
|
708
717
|
barSpacing: 0,
|
|
709
|
-
// Rounded bar caps (px). 0 = square (default). Applies to bars/mirror.
|
|
710
|
-
barRadius:
|
|
718
|
+
// Rounded bar caps (px). 0 = square; 1 = soft caps (default). Applies to bars/mirror.
|
|
719
|
+
barRadius: 1,
|
|
711
720
|
// Color preset: null = auto-detect, 'dark' = force dark, 'light' = force light
|
|
712
721
|
colorPreset: null,
|
|
713
722
|
// Individual color overrides (null means use preset)
|
|
@@ -726,6 +735,9 @@ var DEFAULT_OPTIONS = {
|
|
|
726
735
|
showTime: true,
|
|
727
736
|
showHoverTime: false,
|
|
728
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,
|
|
729
741
|
singlePlay: true,
|
|
730
742
|
playOnSeek: true,
|
|
731
743
|
enableMediaSession: true,
|
|
@@ -758,7 +770,7 @@ var DEFAULT_OPTIONS = {
|
|
|
758
770
|
};
|
|
759
771
|
var STYLE_DEFAULTS = {
|
|
760
772
|
bars: { barWidth: 3, barSpacing: 1 },
|
|
761
|
-
mirror: { barWidth: 2, barSpacing:
|
|
773
|
+
mirror: { barWidth: 2, barSpacing: 2 },
|
|
762
774
|
line: { barWidth: 2, barSpacing: 0 },
|
|
763
775
|
blocks: { barWidth: 4, barSpacing: 2 },
|
|
764
776
|
dots: { barWidth: 3, barSpacing: 3 },
|
|
@@ -925,7 +937,7 @@ var WaveformPlayer = class _WaveformPlayer {
|
|
|
925
937
|
this.container.classList.add("waveform-layout-preview");
|
|
926
938
|
}
|
|
927
939
|
const buttonHTML = this.options.showControls ? `
|
|
928
|
-
<button class="waveform-btn" aria-label="Play/Pause" style="
|
|
940
|
+
<button class="waveform-btn${this.options.buttonStyle === "minimal" ? " waveform-btn-minimal" : ""}" aria-label="Play/Pause" style="
|
|
929
941
|
border-color: ${this.options.buttonColor};
|
|
930
942
|
color: ${this.options.buttonColor};
|
|
931
943
|
">
|
|
@@ -1010,6 +1022,7 @@ var WaveformPlayer = class _WaveformPlayer {
|
|
|
1010
1022
|
this.speedBtn = this.container.querySelector(".speed-btn");
|
|
1011
1023
|
this.speedMenu = this.container.querySelector(".speed-menu");
|
|
1012
1024
|
this.resizeCanvas();
|
|
1025
|
+
this.updateBPMDisplay();
|
|
1013
1026
|
}
|
|
1014
1027
|
/**
|
|
1015
1028
|
* Create audio element
|
|
@@ -1815,8 +1828,9 @@ var WaveformPlayer = class _WaveformPlayer {
|
|
|
1815
1828
|
* @private
|
|
1816
1829
|
*/
|
|
1817
1830
|
updateBPMDisplay() {
|
|
1818
|
-
|
|
1819
|
-
|
|
1831
|
+
const bpm = this.options.bpm || this.detectedBPM;
|
|
1832
|
+
if (this.bpmEl && this.bpmValueEl && bpm) {
|
|
1833
|
+
this.bpmValueEl.textContent = Math.round(bpm);
|
|
1820
1834
|
this.bpmEl.style.display = "inline-flex";
|
|
1821
1835
|
}
|
|
1822
1836
|
}
|