@nikelroot/video-player 0.3.0 → 0.3.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.
package/dist/index.cjs CHANGED
@@ -1404,7 +1404,7 @@ var VideoPlayerBase = (props, ref) => {
1404
1404
  } else {
1405
1405
  h.startLoad();
1406
1406
  }
1407
- if (resumeSnapshot.current ? resumeSnapshot.current.playing : autoPlay) void playAction();
1407
+ if (resumeSnapshot.current ? resumeSnapshot.current.playing : propsRef.current.autoPlay) void playAction();
1408
1408
  });
1409
1409
  h.on(HlsCtor.Events.FRAG_BUFFERED, (_evt, data) => {
1410
1410
  if (isStaleLoad()) return;
@@ -1441,7 +1441,7 @@ var VideoPlayerBase = (props, ref) => {
1441
1441
  video.src = videoSrc;
1442
1442
  if (!(options == null ? void 0 : options.metadataOnly)) {
1443
1443
  video.currentTime = (_b = (_a = resumeSnapshot.current) == null ? void 0 : _a.time) != null ? _b : initialTime;
1444
- if (resumeSnapshot.current ? resumeSnapshot.current.playing : autoPlay) void playAction();
1444
+ if (resumeSnapshot.current ? resumeSnapshot.current.playing : propsRef.current.autoPlay) void playAction();
1445
1445
  }
1446
1446
  },
1447
1447
  [autoPlay, initialTime, playAction, videoSrc]
@@ -1657,10 +1657,13 @@ var VideoPlayerBase = (props, ref) => {
1657
1657
  videoSrc
1658
1658
  ]);
1659
1659
  (0, import_react4.useEffect)(() => {
1660
- if (!autoPlay) return;
1661
1660
  if (resumeSnapshot.current) return;
1662
- if (!canAttemptPlayback(videoRef.current)) return;
1663
- void playAction();
1661
+ if (!canAttemptPlayback(videoRef.current)) {
1662
+ pendingPlay.current = Boolean(autoPlay);
1663
+ playbackIntent.current = Boolean(autoPlay);
1664
+ return;
1665
+ }
1666
+ if (autoPlay) void playAction();
1664
1667
  }, [autoPlay, playAction]);
1665
1668
  (0, import_react4.useEffect)(() => {
1666
1669
  if (typeof document === "undefined") return;
@@ -1753,7 +1756,10 @@ var VideoPlayerBase = (props, ref) => {
1753
1756
  setNextPlaying(true);
1754
1757
  },
1755
1758
  onPause: () => {
1756
- if (!resumeSnapshot.current) setNextPlaying(false);
1759
+ if (!resumeSnapshot.current) {
1760
+ playbackIntent.current = false;
1761
+ setNextPlaying(false);
1762
+ }
1757
1763
  },
1758
1764
  onEnded: () => setNextPlaying(false),
1759
1765
  onLoadedMetadata: videoLoadedHandler,
package/dist/index.js CHANGED
@@ -1375,7 +1375,7 @@ var VideoPlayerBase = (props, ref) => {
1375
1375
  } else {
1376
1376
  h.startLoad();
1377
1377
  }
1378
- if (resumeSnapshot.current ? resumeSnapshot.current.playing : autoPlay) void playAction();
1378
+ if (resumeSnapshot.current ? resumeSnapshot.current.playing : propsRef.current.autoPlay) void playAction();
1379
1379
  });
1380
1380
  h.on(HlsCtor.Events.FRAG_BUFFERED, (_evt, data) => {
1381
1381
  if (isStaleLoad()) return;
@@ -1412,7 +1412,7 @@ var VideoPlayerBase = (props, ref) => {
1412
1412
  video.src = videoSrc;
1413
1413
  if (!(options == null ? void 0 : options.metadataOnly)) {
1414
1414
  video.currentTime = (_b = (_a = resumeSnapshot.current) == null ? void 0 : _a.time) != null ? _b : initialTime;
1415
- if (resumeSnapshot.current ? resumeSnapshot.current.playing : autoPlay) void playAction();
1415
+ if (resumeSnapshot.current ? resumeSnapshot.current.playing : propsRef.current.autoPlay) void playAction();
1416
1416
  }
1417
1417
  },
1418
1418
  [autoPlay, initialTime, playAction, videoSrc]
@@ -1628,10 +1628,13 @@ var VideoPlayerBase = (props, ref) => {
1628
1628
  videoSrc
1629
1629
  ]);
1630
1630
  useEffect2(() => {
1631
- if (!autoPlay) return;
1632
1631
  if (resumeSnapshot.current) return;
1633
- if (!canAttemptPlayback(videoRef.current)) return;
1634
- void playAction();
1632
+ if (!canAttemptPlayback(videoRef.current)) {
1633
+ pendingPlay.current = Boolean(autoPlay);
1634
+ playbackIntent.current = Boolean(autoPlay);
1635
+ return;
1636
+ }
1637
+ if (autoPlay) void playAction();
1635
1638
  }, [autoPlay, playAction]);
1636
1639
  useEffect2(() => {
1637
1640
  if (typeof document === "undefined") return;
@@ -1724,7 +1727,10 @@ var VideoPlayerBase = (props, ref) => {
1724
1727
  setNextPlaying(true);
1725
1728
  },
1726
1729
  onPause: () => {
1727
- if (!resumeSnapshot.current) setNextPlaying(false);
1730
+ if (!resumeSnapshot.current) {
1731
+ playbackIntent.current = false;
1732
+ setNextPlaying(false);
1733
+ }
1728
1734
  },
1729
1735
  onEnded: () => setNextPlaying(false),
1730
1736
  onLoadedMetadata: videoLoadedHandler,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nikelroot/video-player",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Standalone React video player with HLS support.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",