@waveform-playlist/ui-components 11.3.1 → 12.1.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/index.mjs CHANGED
@@ -1487,6 +1487,7 @@ var PlayheadWithMarker = ({
1487
1487
  color = "#ff0000",
1488
1488
  isPlaying,
1489
1489
  currentTimeRef,
1490
+ visualTimeRef,
1490
1491
  playbackStartTimeRef,
1491
1492
  audioStartPositionRef,
1492
1493
  samplesPerPixel,
@@ -1501,7 +1502,9 @@ var PlayheadWithMarker = ({
1501
1502
  const updatePosition = () => {
1502
1503
  if (containerRef.current) {
1503
1504
  let time;
1504
- if (isPlaying) {
1505
+ if (visualTimeRef?.current !== void 0 && visualTimeRef.current !== null) {
1506
+ time = visualTimeRef.current;
1507
+ } else if (isPlaying) {
1505
1508
  if (getPlaybackTime) {
1506
1509
  time = getPlaybackTime();
1507
1510
  } else if (getAudioContextTime) {
@@ -1537,6 +1540,7 @@ var PlayheadWithMarker = ({
1537
1540
  samplesPerPixel,
1538
1541
  controlsOffset,
1539
1542
  currentTimeRef,
1543
+ visualTimeRef,
1540
1544
  playbackStartTimeRef,
1541
1545
  audioStartPositionRef,
1542
1546
  getAudioContextTime,
@@ -1544,7 +1548,7 @@ var PlayheadWithMarker = ({
1544
1548
  ]);
1545
1549
  useEffect3(() => {
1546
1550
  if (!isPlaying && containerRef.current) {
1547
- const time = currentTimeRef.current ?? 0;
1551
+ const time = visualTimeRef?.current ?? currentTimeRef.current ?? 0;
1548
1552
  const pos = time * sampleRate / samplesPerPixel + controlsOffset;
1549
1553
  containerRef.current.style.transform = `translate3d(${pos}px, 0, 0)`;
1550
1554
  }
@@ -2786,11 +2790,20 @@ var StyledTimeScale = withTheme2(TimeScale);
2786
2790
  import {
2787
2791
  PPQN,
2788
2792
  ticksToSamples,
2789
- ticksToBarBeatLabel,
2793
+ ticksPerBeat as ticksPerBeat2,
2794
+ ticksPerBar as ticksPerBar2,
2790
2795
  samplesToPixels,
2791
2796
  secondsToPixels
2792
2797
  } from "@waveform-playlist/core";
2793
2798
  import { jsx as jsx27 } from "react/jsx-runtime";
2799
+ function ticksToBarBeatLabel(ticks, timeSignature, ppqn = PPQN) {
2800
+ const barTicks = ticksPerBar2(timeSignature, ppqn);
2801
+ const beatTicks = ticksPerBeat2(timeSignature, ppqn);
2802
+ const bar = Math.floor(ticks / barTicks) + 1;
2803
+ const beatInBar = Math.floor(ticks % barTicks / beatTicks) + 1;
2804
+ if (beatInBar === 1) return `${bar}`;
2805
+ return `${bar}.${beatInBar}`;
2806
+ }
2794
2807
  var timeinfo = /* @__PURE__ */ new Map([
2795
2808
  [700, { marker: 1e3, bigStep: 500, smallStep: 100 }],
2796
2809
  [1500, { marker: 2e3, bigStep: 1e3, smallStep: 200 }],