@waveform-playlist/ui-components 7.1.3 → 8.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.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -322,9 +322,9 @@ interface PlayheadProps {
|
|
|
322
322
|
isPlaying: boolean;
|
|
323
323
|
/** Ref to current time in seconds - use for smooth animation during playback */
|
|
324
324
|
currentTimeRef: react__default.RefObject<number>;
|
|
325
|
-
/** Audio context start time when playback began
|
|
325
|
+
/** Audio context start time when playback began. Fallback when getPlaybackTime is not provided. */
|
|
326
326
|
playbackStartTimeRef: react__default.RefObject<number>;
|
|
327
|
-
/** Audio position when playback started
|
|
327
|
+
/** Audio position when playback started. Fallback when getPlaybackTime is not provided. */
|
|
328
328
|
audioStartPositionRef: react__default.RefObject<number>;
|
|
329
329
|
/** Samples per pixel - for converting time to pixels */
|
|
330
330
|
samplesPerPixel: number;
|
|
@@ -334,6 +334,8 @@ interface PlayheadProps {
|
|
|
334
334
|
controlsOffset: number;
|
|
335
335
|
/** Function to get current audio context time - required for smooth animation */
|
|
336
336
|
getAudioContextTime?: () => number;
|
|
337
|
+
/** Returns current playback time (auto-wraps at loop boundaries). Preferred over manual elapsed calculation. */
|
|
338
|
+
getPlaybackTime?: () => number;
|
|
337
339
|
}
|
|
338
340
|
/**
|
|
339
341
|
* Type for custom playhead render functions.
|
package/dist/index.d.ts
CHANGED
|
@@ -322,9 +322,9 @@ interface PlayheadProps {
|
|
|
322
322
|
isPlaying: boolean;
|
|
323
323
|
/** Ref to current time in seconds - use for smooth animation during playback */
|
|
324
324
|
currentTimeRef: react__default.RefObject<number>;
|
|
325
|
-
/** Audio context start time when playback began
|
|
325
|
+
/** Audio context start time when playback began. Fallback when getPlaybackTime is not provided. */
|
|
326
326
|
playbackStartTimeRef: react__default.RefObject<number>;
|
|
327
|
-
/** Audio position when playback started
|
|
327
|
+
/** Audio position when playback started. Fallback when getPlaybackTime is not provided. */
|
|
328
328
|
audioStartPositionRef: react__default.RefObject<number>;
|
|
329
329
|
/** Samples per pixel - for converting time to pixels */
|
|
330
330
|
samplesPerPixel: number;
|
|
@@ -334,6 +334,8 @@ interface PlayheadProps {
|
|
|
334
334
|
controlsOffset: number;
|
|
335
335
|
/** Function to get current audio context time - required for smooth animation */
|
|
336
336
|
getAudioContextTime?: () => number;
|
|
337
|
+
/** Returns current playback time (auto-wraps at loop boundaries). Preferred over manual elapsed calculation. */
|
|
338
|
+
getPlaybackTime?: () => number;
|
|
337
339
|
}
|
|
338
340
|
/**
|
|
339
341
|
* Type for custom playhead render functions.
|
package/dist/index.js
CHANGED
|
@@ -1420,7 +1420,8 @@ var PlayheadWithMarker = ({
|
|
|
1420
1420
|
samplesPerPixel,
|
|
1421
1421
|
sampleRate,
|
|
1422
1422
|
controlsOffset,
|
|
1423
|
-
getAudioContextTime
|
|
1423
|
+
getAudioContextTime,
|
|
1424
|
+
getPlaybackTime
|
|
1424
1425
|
}) => {
|
|
1425
1426
|
const containerRef = (0, import_react7.useRef)(null);
|
|
1426
1427
|
const animationFrameRef = (0, import_react7.useRef)(null);
|
|
@@ -1428,9 +1429,15 @@ var PlayheadWithMarker = ({
|
|
|
1428
1429
|
const updatePosition = () => {
|
|
1429
1430
|
if (containerRef.current) {
|
|
1430
1431
|
let time;
|
|
1431
|
-
if (isPlaying
|
|
1432
|
-
|
|
1433
|
-
|
|
1432
|
+
if (isPlaying) {
|
|
1433
|
+
if (getPlaybackTime) {
|
|
1434
|
+
time = getPlaybackTime();
|
|
1435
|
+
} else if (getAudioContextTime) {
|
|
1436
|
+
const elapsed = getAudioContextTime() - (playbackStartTimeRef.current ?? 0);
|
|
1437
|
+
time = (audioStartPositionRef.current ?? 0) + elapsed;
|
|
1438
|
+
} else {
|
|
1439
|
+
time = currentTimeRef.current ?? 0;
|
|
1440
|
+
}
|
|
1434
1441
|
} else {
|
|
1435
1442
|
time = currentTimeRef.current ?? 0;
|
|
1436
1443
|
}
|
|
@@ -1460,7 +1467,8 @@ var PlayheadWithMarker = ({
|
|
|
1460
1467
|
currentTimeRef,
|
|
1461
1468
|
playbackStartTimeRef,
|
|
1462
1469
|
audioStartPositionRef,
|
|
1463
|
-
getAudioContextTime
|
|
1470
|
+
getAudioContextTime,
|
|
1471
|
+
getPlaybackTime
|
|
1464
1472
|
]);
|
|
1465
1473
|
(0, import_react7.useEffect)(() => {
|
|
1466
1474
|
if (!isPlaying && containerRef.current) {
|