@arraypress/waveform-player 1.9.0 → 1.11.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 +25 -7
- package/dist/waveform-player.cjs.map +2 -2
- package/dist/waveform-player.css +1 -1
- package/dist/waveform-player.esm.js +9 -9
- package/dist/waveform-player.esm.js.map +3 -3
- package/dist/waveform-player.js +25 -7
- package/dist/waveform-player.min.js +9 -9
- package/dist/waveform-player.min.js.map +3 -3
- package/index.d.ts +12 -0
- package/package.json +1 -1
- package/src/css/waveform-player.css +47 -4
- package/src/js/core.js +9 -2
- package/src/js/themes.js +17 -5
- package/src/js/utils.js +2 -0
package/dist/waveform-player.cjs
CHANGED
|
@@ -85,6 +85,8 @@ function parseDataAttributes(element) {
|
|
|
85
85
|
setNum("barSpacing");
|
|
86
86
|
setNum("barRadius");
|
|
87
87
|
if (element.dataset.buttonAlign) options.buttonAlign = element.dataset.buttonAlign;
|
|
88
|
+
if (element.dataset.layout) options.layout = element.dataset.layout;
|
|
89
|
+
if (element.dataset.buttonStyle) options.buttonStyle = element.dataset.buttonStyle;
|
|
88
90
|
if (element.dataset.colorPreset) options.colorPreset = element.dataset.colorPreset;
|
|
89
91
|
if (element.dataset.waveformColor) options.waveformColor = parseColorValue(element.dataset.waveformColor);
|
|
90
92
|
if (element.dataset.progressColor) options.progressColor = parseColorValue(element.dataset.progressColor);
|
|
@@ -681,8 +683,11 @@ function getColorPreset(presetName) {
|
|
|
681
683
|
var DEFAULT_OPTIONS = {
|
|
682
684
|
// Core settings
|
|
683
685
|
url: "",
|
|
684
|
-
height:
|
|
685
|
-
|
|
686
|
+
height: 64,
|
|
687
|
+
// Source peak resolution. The drawer resamples these to fit
|
|
688
|
+
// canvasWidth / (barWidth + barSpacing) bars, so this is fidelity headroom,
|
|
689
|
+
// not the visible bar count.
|
|
690
|
+
samples: 256,
|
|
686
691
|
preload: "metadata",
|
|
687
692
|
// Audio mode — 'self' = player owns the <audio> element (default, current
|
|
688
693
|
// behavior). 'external' = player is a visualization-only surface; no audio
|
|
@@ -696,12 +701,21 @@ var DEFAULT_OPTIONS = {
|
|
|
696
701
|
playbackRates: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2],
|
|
697
702
|
// Layout Options
|
|
698
703
|
buttonAlign: "auto",
|
|
704
|
+
// Player layout. 'default' = play button + waveform with a left-aligned
|
|
705
|
+
// info row below. 'preview' = compact: the title is centered under the
|
|
706
|
+
// waveform and the meta row (time / speed / BPM) is trimmed — ideal for
|
|
707
|
+
// sample-pack sample previews and dense grids.
|
|
708
|
+
layout: "default",
|
|
709
|
+
// Play/pause button style. 'circle' = bordered circle (default).
|
|
710
|
+
// 'minimal' = a bare play/pause glyph with no circle — the look sample-pack
|
|
711
|
+
// and beat stores use in their preview grids.
|
|
712
|
+
buttonStyle: "circle",
|
|
699
713
|
// Default waveform style
|
|
700
714
|
waveformStyle: "mirror",
|
|
701
715
|
barWidth: 2,
|
|
702
716
|
barSpacing: 0,
|
|
703
|
-
// Rounded bar caps (px). 0 = square (default). Applies to bars/mirror.
|
|
704
|
-
barRadius:
|
|
717
|
+
// Rounded bar caps (px). 0 = square; 1 = soft caps (default). Applies to bars/mirror.
|
|
718
|
+
barRadius: 1,
|
|
705
719
|
// Color preset: null = auto-detect, 'dark' = force dark, 'light' = force light
|
|
706
720
|
colorPreset: null,
|
|
707
721
|
// Individual color overrides (null means use preset)
|
|
@@ -752,7 +766,7 @@ var DEFAULT_OPTIONS = {
|
|
|
752
766
|
};
|
|
753
767
|
var STYLE_DEFAULTS = {
|
|
754
768
|
bars: { barWidth: 3, barSpacing: 1 },
|
|
755
|
-
mirror: { barWidth: 2, barSpacing:
|
|
769
|
+
mirror: { barWidth: 2, barSpacing: 2 },
|
|
756
770
|
line: { barWidth: 2, barSpacing: 0 },
|
|
757
771
|
blocks: { barWidth: 4, barSpacing: 2 },
|
|
758
772
|
dots: { barWidth: 3, barSpacing: 3 },
|
|
@@ -914,8 +928,12 @@ var WaveformPlayer = class _WaveformPlayer {
|
|
|
914
928
|
buttonAlign = "center";
|
|
915
929
|
}
|
|
916
930
|
}
|
|
931
|
+
const isPreview = this.options.layout === "preview";
|
|
932
|
+
if (isPreview) {
|
|
933
|
+
this.container.classList.add("waveform-layout-preview");
|
|
934
|
+
}
|
|
917
935
|
const buttonHTML = this.options.showControls ? `
|
|
918
|
-
<button class="waveform-btn" aria-label="Play/Pause" style="
|
|
936
|
+
<button class="waveform-btn${this.options.buttonStyle === "minimal" ? " waveform-btn-minimal" : ""}" aria-label="Play/Pause" style="
|
|
919
937
|
border-color: ${this.options.buttonColor};
|
|
920
938
|
color: ${this.options.buttonColor};
|
|
921
939
|
">
|
|
@@ -938,7 +956,7 @@ var WaveformPlayer = class _WaveformPlayer {
|
|
|
938
956
|
<span class="waveform-title" style="color: ${this.options.textColor};"></span>
|
|
939
957
|
${this.options.subtitle ? `<span class="waveform-subtitle" style="color: ${this.options.textSecondaryColor};">${this.options.subtitle}</span>` : ""}
|
|
940
958
|
</div>
|
|
941
|
-
<div style="display: flex; align-items: center; gap: 1rem;">
|
|
959
|
+
<div class="waveform-meta" style="display: flex; align-items: center; gap: 1rem;">
|
|
942
960
|
${this.options.showBPM ? `
|
|
943
961
|
<span class="waveform-bpm" style="color: ${this.options.textSecondaryColor}; display: none;">
|
|
944
962
|
<span class="bpm-value">--</span> BPM
|