@waveform-playlist/browser 15.3.3 → 15.3.4

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
@@ -1886,6 +1886,7 @@ var WaveformPlaylistProvider = ({
1886
1886
  const playbackStartTimeRef = useRef9(0);
1887
1887
  const audioStartPositionRef = useRef9(0);
1888
1888
  const playbackEndTimeRef = useRef9(null);
1889
+ const suppressEngineStopMirrorRef = useRef9(false);
1889
1890
  const scrollContainerRef = useRef9(null);
1890
1891
  const isAutomaticScrollRef = useRef9(false);
1891
1892
  const frameCallbacksRef = useRef9(/* @__PURE__ */ new Map());
@@ -2094,7 +2095,9 @@ var WaveformPlaylistProvider = ({
2094
2095
  const wasPlaying = isPlayingRef.current;
2095
2096
  const resumePosition = currentTimeRef.current;
2096
2097
  if (engineRef.current && wasPlaying) {
2098
+ suppressEngineStopMirrorRef.current = true;
2097
2099
  engineRef.current.stop();
2100
+ suppressEngineStopMirrorRef.current = false;
2098
2101
  stopAnimationFrameLoop();
2099
2102
  pendingResumeRef.current = { position: resumePosition };
2100
2103
  }
@@ -2194,6 +2197,14 @@ var WaveformPlaylistProvider = ({
2194
2197
  }
2195
2198
  }
2196
2199
  });
2200
+ engine.on("stop", () => {
2201
+ if (suppressEngineStopMirrorRef.current) return;
2202
+ setIsPlaying(false);
2203
+ stopAnimationFrameLoop();
2204
+ const stoppedAt = engine.getCurrentTime();
2205
+ setCurrentTimeRefs(stoppedAt);
2206
+ setCurrentTime(stoppedAt);
2207
+ });
2197
2208
  engine.setTracks(tracksWithState);
2198
2209
  suppressTracksMirroring = false;
2199
2210
  lastTracksVersionRef.current = engine.getState().tracksVersion;
@@ -2491,7 +2502,9 @@ var WaveformPlaylistProvider = ({
2491
2502
  if (isPlaying && animationFrameRef.current && engineRef.current) {
2492
2503
  if (continuousPlay) {
2493
2504
  const currentPos = currentTimeRef.current;
2505
+ suppressEngineStopMirrorRef.current = true;
2494
2506
  engineRef.current.stop();
2507
+ suppressEngineStopMirrorRef.current = false;
2495
2508
  stopAnimationLoop();
2496
2509
  const timeNow = getAudioContextTime();
2497
2510
  playbackStartTimeRef.current = timeNow;
@@ -2546,7 +2559,9 @@ var WaveformPlaylistProvider = ({
2546
2559
  const actualStartTime = startTime != null ? startTime : currentTimeRef.current;
2547
2560
  playStartPositionRef.current = actualStartTime;
2548
2561
  setCurrentTimeRefs(actualStartTime);
2562
+ suppressEngineStopMirrorRef.current = true;
2549
2563
  engineRef.current.stop();
2564
+ suppressEngineStopMirrorRef.current = false;
2550
2565
  engineRef.current.seek(actualStartTime);
2551
2566
  stopAnimationLoop();
2552
2567
  const startTimeNow = getAudioContextTime();
@@ -2661,7 +2676,9 @@ var WaveformPlaylistProvider = ({
2661
2676
  setCurrentTimeRefs(start);
2662
2677
  setCurrentTime(start);
2663
2678
  if (isPlaying && engineRef.current) {
2679
+ suppressEngineStopMirrorRef.current = true;
2664
2680
  engineRef.current.stop();
2681
+ suppressEngineStopMirrorRef.current = false;
2665
2682
  engineRef.current.seek(start);
2666
2683
  engineRef.current.play(start);
2667
2684
  }