@arraypress/waveform-player 1.13.1 → 1.15.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 +17 -6
- package/dist/waveform-player.cjs.map +2 -2
- package/dist/waveform-player.css +1 -1
- package/dist/waveform-player.esm.js +3 -2
- package/dist/waveform-player.esm.js.map +3 -3
- package/dist/waveform-player.js +17 -6
- package/dist/waveform-player.min.js +3 -2
- package/dist/waveform-player.min.js.map +3 -3
- package/index.d.ts +9 -1
- package/package.json +1 -1
- package/src/css/waveform-player.css +21 -14
- package/src/js/audio.js +12 -7
- package/src/js/core.js +1 -0
- package/src/js/themes.js +11 -4
- package/src/js/utils.js +6 -0
package/dist/waveform-player.cjs
CHANGED
|
@@ -87,6 +87,10 @@ function parseDataAttributes(element) {
|
|
|
87
87
|
if (element.dataset.buttonAlign) options.buttonAlign = element.dataset.buttonAlign;
|
|
88
88
|
if (element.dataset.layout) options.layout = element.dataset.layout;
|
|
89
89
|
if (element.dataset.buttonStyle) options.buttonStyle = element.dataset.buttonStyle;
|
|
90
|
+
if (element.dataset.buttonSize) {
|
|
91
|
+
const bs = element.dataset.buttonSize;
|
|
92
|
+
options.buttonSize = /^\d+(\.\d+)?$/.test(bs.trim()) ? parseFloat(bs) : bs;
|
|
93
|
+
}
|
|
90
94
|
if (element.dataset.colorPreset) options.colorPreset = element.dataset.colorPreset;
|
|
91
95
|
if (element.dataset.waveformColor) options.waveformColor = parseColorValue(element.dataset.waveformColor);
|
|
92
96
|
if (element.dataset.progressColor) options.progressColor = parseColorValue(element.dataset.progressColor);
|
|
@@ -564,7 +568,6 @@ function detectOnsets(channelData, sampleRate) {
|
|
|
564
568
|
// src/js/audio.js
|
|
565
569
|
function extractPeaks(buffer, samples = 200) {
|
|
566
570
|
const sampleSize = buffer.length / samples;
|
|
567
|
-
const sampleStep = ~~(sampleSize / 10) || 1;
|
|
568
571
|
const channels = buffer.numberOfChannels;
|
|
569
572
|
const peaks = [];
|
|
570
573
|
for (let c = 0; c < channels; c++) {
|
|
@@ -574,7 +577,7 @@ function extractPeaks(buffer, samples = 200) {
|
|
|
574
577
|
const end = ~~(start + sampleSize);
|
|
575
578
|
let min = 0;
|
|
576
579
|
let max = 0;
|
|
577
|
-
for (let j = start; j < end; j
|
|
580
|
+
for (let j = start; j < end; j++) {
|
|
578
581
|
const value = chan[j];
|
|
579
582
|
if (value > max) max = value;
|
|
580
583
|
if (value < min) min = value;
|
|
@@ -685,10 +688,12 @@ var DEFAULT_OPTIONS = {
|
|
|
685
688
|
// Core settings
|
|
686
689
|
url: "",
|
|
687
690
|
height: 64,
|
|
688
|
-
// Source peak resolution
|
|
689
|
-
// canvasWidth / (barWidth + barSpacing)
|
|
690
|
-
// not the visible bar count.
|
|
691
|
-
|
|
691
|
+
// Source peak resolution for LIVE decode (ignored when peaks are supplied).
|
|
692
|
+
// The drawer resamples these to fit canvasWidth / (barWidth + barSpacing)
|
|
693
|
+
// bars, so this is fidelity headroom, not the visible bar count. 1800 (the
|
|
694
|
+
// SoundCloud/WaveformGen figure) keeps wide / high-DPI waveforms crisp; the
|
|
695
|
+
// every-frame scan means a higher value costs no extra extraction time.
|
|
696
|
+
samples: 1800,
|
|
692
697
|
preload: "metadata",
|
|
693
698
|
// Audio mode — 'self' = player owns the <audio> element (default, current
|
|
694
699
|
// behavior). 'external' = player is a visualization-only surface; no audio
|
|
@@ -711,6 +716,11 @@ var DEFAULT_OPTIONS = {
|
|
|
711
716
|
// 'minimal' = a bare play/pause glyph with no circle — the look sample-pack
|
|
712
717
|
// and beat stores use in their preview grids.
|
|
713
718
|
buttonStyle: "circle",
|
|
719
|
+
// Play/pause button size. null = the stylesheet default (36px circle /
|
|
720
|
+
// proportional minimal). A number is treated as px; a string (e.g. '4rem')
|
|
721
|
+
// is used verbatim. Sets the `--wfp-btn-size` CSS var, which scales BOTH
|
|
722
|
+
// styles — box and glyph — proportionally.
|
|
723
|
+
buttonSize: null,
|
|
714
724
|
// Default waveform style
|
|
715
725
|
waveformStyle: "mirror",
|
|
716
726
|
barWidth: 2,
|
|
@@ -944,6 +954,7 @@ var WaveformPlayer = class _WaveformPlayer {
|
|
|
944
954
|
<button class="waveform-btn${this.options.buttonStyle === "minimal" ? " waveform-btn-minimal" : ""}" aria-label="Play/Pause" style="
|
|
945
955
|
border-color: ${this.options.buttonColor};
|
|
946
956
|
color: ${this.options.buttonColor};
|
|
957
|
+
${this.options.buttonSize != null ? `--wfp-btn-size: ${typeof this.options.buttonSize === "number" ? `${this.options.buttonSize}px` : this.options.buttonSize};` : ""}
|
|
947
958
|
">
|
|
948
959
|
<span class="waveform-icon-play">${this.options.playIcon}</span>
|
|
949
960
|
<span class="waveform-icon-pause" style="display:none;">${this.options.pauseIcon}</span>
|