miriad-viz 0.6.0 → 0.7.1

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.
@@ -2406,7 +2406,6 @@ function progressToAudioPosition(progress, timingFile) {
2406
2406
  }
2407
2407
 
2408
2408
  // src/viewer/useAudioPlayback.ts
2409
- var SEEK_TOLERANCE_SEC = 0.15;
2410
2409
  function useAudioPlayback({
2411
2410
  progress,
2412
2411
  playing,
@@ -2415,6 +2414,7 @@ function useAudioPlayback({
2415
2414
  }) {
2416
2415
  const audioCache = react.useRef(/* @__PURE__ */ new Map());
2417
2416
  const activeClipRef = react.useRef(null);
2417
+ const prevProgressRef = react.useRef(0);
2418
2418
  const baseUrl = audioBaseUrl.endsWith("/") ? audioBaseUrl : `${audioBaseUrl}/`;
2419
2419
  const getAudio = react.useCallback(
2420
2420
  (clipId, audioFile) => {
@@ -2495,15 +2495,20 @@ function useAudioPlayback({
2495
2495
  audio.play().catch(() => {
2496
2496
  });
2497
2497
  } else {
2498
- const drift = Math.abs(audio.currentTime - offsetSec);
2499
- if (drift > SEEK_TOLERANCE_SEC) {
2500
- audio.currentTime = offsetSec;
2498
+ const progressDelta = Math.abs(progress - prevProgressRef.current);
2499
+ const isLikelyScrub = progressDelta > 0.01;
2500
+ if (isLikelyScrub) {
2501
+ const drift = Math.abs(audio.currentTime - offsetSec);
2502
+ if (drift > 0.3) {
2503
+ audio.currentTime = offsetSec;
2504
+ }
2501
2505
  }
2502
2506
  if (audio.paused) {
2503
2507
  audio.play().catch(() => {
2504
2508
  });
2505
2509
  }
2506
2510
  }
2511
+ prevProgressRef.current = progress;
2507
2512
  }, [progress, playing, timingFile, getAudio, stopAll]);
2508
2513
  return { forceLoadAll };
2509
2514
  }