softbuilders-react-video-player 1.1.55 → 1.1.57

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -31,10 +31,10 @@ var __objRest = (source, exclude) => {
31
31
  };
32
32
 
33
33
  // src/components/SoftBuildersVideoPlayer/index.tsx
34
- import { memo, useEffect as useEffect15, useState as useState14 } from "react";
34
+ import { forwardRef as forwardRef2, memo, useEffect as useEffect15, useState as useState14 } from "react";
35
35
 
36
36
  // src/components/VideoPlayerComponent/index.tsx
37
- import { useEffect as useEffect14, useRef as useRef2, useState as useState13 } from "react";
37
+ import { forwardRef, useEffect as useEffect14, useRef as useRef2, useState as useState13 } from "react";
38
38
  import ReactDOM from "react-dom/client";
39
39
  import videojs from "video.js";
40
40
  import "video.js/dist/video-js.css";
@@ -607,7 +607,8 @@ var MenuButton = ({
607
607
  menuContent,
608
608
  close,
609
609
  classContainer,
610
- onClick
610
+ onClick,
611
+ setNoteOpen
611
612
  }) => {
612
613
  const [isOpen, setIsOpen] = useState3(false);
613
614
  const buttonRef = useRef(null);
@@ -628,6 +629,9 @@ var MenuButton = ({
628
629
  useEffect3(() => {
629
630
  if (close) close(closeMenu);
630
631
  }, [close, closeMenu]);
632
+ useEffect3(() => {
633
+ setNoteOpen(isOpen);
634
+ }, [isOpen]);
631
635
  return /* @__PURE__ */ jsxs5("div", { className: "sb-relative sb-flex sb-items-end", children: [
632
636
  /* @__PURE__ */ jsx20(
633
637
  "button",
@@ -780,7 +784,11 @@ var QualityMenu_default = QualityMenu;
780
784
  // src/components/CreateNoteMenu/index.tsx
781
785
  import { useState as useState5 } from "react";
782
786
  import { jsx as jsx22, jsxs as jsxs7 } from "react/jsx-runtime";
783
- var CreateNoteMenu = ({ handleSaveNoteAction, width }) => {
787
+ var CreateNoteMenu = ({
788
+ handleSaveNoteAction,
789
+ width,
790
+ setNoteOpen
791
+ }) => {
784
792
  const { player } = useSoftBuildersVideoPlayerContext();
785
793
  const [note, setNote] = useState5("");
786
794
  const handleSaveNote = () => {
@@ -798,6 +806,7 @@ var CreateNoteMenu = ({ handleSaveNoteAction, width }) => {
798
806
  return /* @__PURE__ */ jsx22(
799
807
  MenuButton_default,
800
808
  {
809
+ setNoteOpen,
801
810
  classContainer: `${width < 400 ? "!sb-top-8 -sb-left-[9.75rem]" : ""}`,
802
811
  buttonContent: /* @__PURE__ */ jsx22(ClosedNoteIcon_default, { className: "sb-w-3 sb-h-3" }),
803
812
  menuContent: /* @__PURE__ */ jsx22(
@@ -1225,6 +1234,7 @@ var ControlBar = ({
1225
1234
  handleControlDisplayTimer,
1226
1235
  setIsQualityMenuOpen,
1227
1236
  setIsSubtitleMenuOpen,
1237
+ setNoteOpen,
1228
1238
  disableNote
1229
1239
  }) => {
1230
1240
  const { setPlayer, setDuration } = useSoftBuildersVideoPlayerContext();
@@ -1333,7 +1343,8 @@ var ControlBar = ({
1333
1343
  CreateNoteMenu_default,
1334
1344
  {
1335
1345
  handleSaveNoteAction,
1336
- width
1346
+ width,
1347
+ setNoteOpen
1337
1348
  }
1338
1349
  ),
1339
1350
  /* @__PURE__ */ jsx33(
@@ -1414,7 +1425,7 @@ var renderBigPlayButton = (id, player, isPaused, setIsPaused, opacity = "100") =
1414
1425
  };
1415
1426
  var controlBarRoot = {};
1416
1427
  var renderControlBar = (id, player, isPaused, setIsPaused, duration, notes, chapters, seekStep = 5, handleSaveNoteAction, opacity = "0", handleControlDisplayTimer = () => {
1417
- }, bgColor = "transparent", setIsQualityMenuOpen, setIsSubtitleMenuOpen, disableNote) => {
1428
+ }, bgColor = "transparent", setIsQualityMenuOpen, setIsSubtitleMenuOpen, disableNote, setNoteOpen) => {
1418
1429
  const container = document.getElementById(`video-container-${id}`);
1419
1430
  if (container) {
1420
1431
  container.style.height = "100%";
@@ -1445,75 +1456,165 @@ var renderControlBar = (id, player, isPaused, setIsPaused, duration, notes, chap
1445
1456
  handleControlDisplayTimer,
1446
1457
  setIsSubtitleMenuOpen,
1447
1458
  setIsQualityMenuOpen,
1448
- disableNote
1459
+ disableNote,
1460
+ setNoteOpen
1449
1461
  }
1450
1462
  ) })
1451
1463
  );
1452
1464
  }
1453
1465
  }
1454
1466
  };
1455
- var VideoPlayerComponent = ({
1456
- id,
1457
- options,
1458
- notes,
1459
- chapters,
1460
- startTime = 0,
1461
- handleSaveNoteAction,
1462
- poster,
1463
- onPlay,
1464
- onPause,
1465
- disableNote
1466
- }) => {
1467
- var _a;
1468
- const videoRef = useRef2(void 0);
1469
- const playerRef = useRef2(void 0);
1470
- const [isReady, setIsReady] = useState13(false);
1471
- const [isPaused, setIsPaused] = useState13(!options.autoplay);
1472
- const [duration, setDuration] = useState13(1);
1473
- const [opacity, setOpacity] = useState13("0");
1474
- const [isControlBarPresent, setIsControlBarPresent] = useState13(true);
1475
- const [bgColor, setBgColor] = useState13("transparent");
1476
- const [isQualityMenuOpen, setIsQualityMenuOpen] = useState13(false);
1477
- const [isSubtitleMenuOpen, setIsSubtitleMenuOpen] = useState13(false);
1478
- const [isHovered, setIsHovered] = useState13(false);
1479
- const onReady = (player) => {
1480
- if (playerRef) {
1481
- playerRef.current = player;
1482
- setIsReady(true);
1483
- player == null ? void 0 : player.currentTime(startTime);
1484
- player.on("waiting", () => {
1485
- });
1486
- player.on("dispose", () => {
1487
- videojs.log("player will dispose");
1488
- setIsReady(false);
1489
- });
1490
- player.on("loadedmetadata", () => {
1491
- const d = player.duration() || 0;
1492
- setDuration(d);
1493
- });
1494
- }
1495
- };
1496
- useEffect14(() => {
1497
- if (!playerRef.current) {
1498
- const videoElement = document.createElement("video-js");
1499
- videoElement.setAttribute("playsinline", "true");
1500
- videoElement.classList.add("vjs-big-play-centered");
1501
- if (poster) {
1502
- videoElement.setAttribute("poster", poster);
1467
+ var VideoPlayerComponent = forwardRef(
1468
+ ({
1469
+ id,
1470
+ options,
1471
+ notes,
1472
+ chapters,
1473
+ startTime = 0,
1474
+ handleSaveNoteAction,
1475
+ poster,
1476
+ onPlay,
1477
+ onPause,
1478
+ disableNote,
1479
+ childRef
1480
+ }) => {
1481
+ var _a;
1482
+ const videoRef = useRef2(void 0);
1483
+ const playerRef = useRef2(void 0);
1484
+ const [isReady, setIsReady] = useState13(false);
1485
+ const [isPaused, setIsPaused] = useState13(!options.autoplay);
1486
+ const [duration, setDuration] = useState13(1);
1487
+ const [opacity, setOpacity] = useState13("0");
1488
+ const [isControlBarPresent, setIsControlBarPresent] = useState13(true);
1489
+ const [bgColor, setBgColor] = useState13("transparent");
1490
+ const [isQualityMenuOpen, setIsQualityMenuOpen] = useState13(false);
1491
+ const [isSubtitleMenuOpen, setIsSubtitleMenuOpen] = useState13(false);
1492
+ const [isHovered, setIsHovered] = useState13(false);
1493
+ const [isNoteOpen, setNoteOpen] = useState13(false);
1494
+ const onReady = (player) => {
1495
+ if (playerRef) {
1496
+ playerRef.current = player;
1497
+ setIsReady(true);
1498
+ player == null ? void 0 : player.currentTime(startTime);
1499
+ player.on("waiting", () => {
1500
+ });
1501
+ player.on("dispose", () => {
1502
+ videojs.log("player will dispose");
1503
+ setIsReady(false);
1504
+ });
1505
+ player.on("loadedmetadata", () => {
1506
+ const d = player.duration() || 0;
1507
+ setDuration(d);
1508
+ });
1503
1509
  }
1504
- videoRef.current.appendChild(videoElement);
1505
- videoElement.style.width = "100%";
1506
- videoElement.style.height = "100%";
1507
- videoElement.style.objectFit = "cover";
1508
- playerRef.current = videojs(videoElement, options, () => {
1509
- onReady(playerRef.current);
1510
- });
1511
- }
1512
- return () => {
1510
+ };
1511
+ useEffect14(() => {
1512
+ if (!playerRef.current) {
1513
+ const videoElement = document.createElement("video-js");
1514
+ videoElement.setAttribute("playsinline", "true");
1515
+ videoElement.classList.add("vjs-big-play-centered");
1516
+ if (poster) {
1517
+ videoElement.setAttribute("poster", poster);
1518
+ }
1519
+ videoRef.current.appendChild(videoElement);
1520
+ videoElement.style.width = "100%";
1521
+ videoElement.style.height = "100%";
1522
+ videoElement.style.objectFit = "cover";
1523
+ playerRef.current = videojs(videoElement, options, () => {
1524
+ onReady(playerRef.current);
1525
+ });
1526
+ }
1527
+ return () => {
1528
+ if (playerRef.current) {
1529
+ playerRef.current.dispose();
1530
+ playerRef.current = void 0;
1531
+ setTimeout(() => {
1532
+ if (bigPlayButtonRoot[id]) {
1533
+ bigPlayButtonRoot[id].unmount();
1534
+ bigPlayButtonRoot[id] = void 0;
1535
+ }
1536
+ if (controlBarRoot[id]) {
1537
+ controlBarRoot[id].unmount();
1538
+ controlBarRoot[id] = void 0;
1539
+ }
1540
+ }, 0);
1541
+ }
1542
+ };
1543
+ }, [options, poster]);
1544
+ useEffect14(() => {
1545
+ if (playerRef.current && isReady) {
1546
+ const currentTime = playerRef.current.currentTime() || 0;
1547
+ if (isPaused) {
1548
+ if (onPause) onPause(currentTime);
1549
+ } else {
1550
+ if (onPlay) onPlay(currentTime);
1551
+ }
1552
+ }
1553
+ }, [isPaused, isReady]);
1554
+ useEffect14(() => {
1555
+ if (isReady) {
1556
+ const controlBarTimeout = setTimeout(() => {
1557
+ renderControlBar(
1558
+ id,
1559
+ playerRef.current,
1560
+ isPaused,
1561
+ setIsPaused,
1562
+ duration,
1563
+ notes,
1564
+ chapters,
1565
+ 5,
1566
+ handleSaveNoteAction,
1567
+ opacity,
1568
+ (e) => {
1569
+ handlePlayerClick(e, true);
1570
+ },
1571
+ bgColor,
1572
+ setIsQualityMenuOpen,
1573
+ setIsSubtitleMenuOpen,
1574
+ disableNote
1575
+ );
1576
+ }, 500);
1577
+ return () => clearTimeout(controlBarTimeout);
1578
+ }
1579
+ }, [
1580
+ id,
1581
+ playerRef,
1582
+ isPaused,
1583
+ setIsPaused,
1584
+ notes,
1585
+ chapters,
1586
+ isReady,
1587
+ handleSaveNoteAction,
1588
+ duration,
1589
+ opacity
1590
+ ]);
1591
+ useEffect14(() => {
1592
+ if (isReady) {
1593
+ const playButtonTimeout = setTimeout(() => {
1594
+ renderBigPlayButton(
1595
+ id,
1596
+ playerRef.current,
1597
+ isPaused,
1598
+ setIsPaused,
1599
+ opacity
1600
+ );
1601
+ }, 500);
1602
+ return () => clearTimeout(playButtonTimeout);
1603
+ }
1604
+ }, [id, isPaused, isReady, opacity]);
1605
+ useEffect14(() => {
1513
1606
  if (playerRef.current) {
1514
- playerRef.current.dispose();
1515
- playerRef.current = void 0;
1516
- setTimeout(() => {
1607
+ const intervalId = setInterval(() => {
1608
+ if (playerRef.current) setIsPaused(playerRef.current.paused());
1609
+ }, 500);
1610
+ return () => clearInterval(intervalId);
1611
+ }
1612
+ }, []);
1613
+ useEffect14(() => {
1614
+ return () => {
1615
+ if (playerRef.current) {
1616
+ playerRef.current.dispose();
1617
+ playerRef.current = void 0;
1517
1618
  if (bigPlayButtonRoot[id]) {
1518
1619
  bigPlayButtonRoot[id].unmount();
1519
1620
  bigPlayButtonRoot[id] = void 0;
@@ -1522,234 +1623,166 @@ var VideoPlayerComponent = ({
1522
1623
  controlBarRoot[id].unmount();
1523
1624
  controlBarRoot[id] = void 0;
1524
1625
  }
1525
- }, 0);
1526
- }
1527
- };
1528
- }, [options, poster]);
1529
- useEffect14(() => {
1530
- if (playerRef.current && isReady) {
1531
- const currentTime = playerRef.current.currentTime() || 0;
1532
- if (isPaused) {
1533
- if (onPause) onPause(currentTime);
1626
+ }
1627
+ };
1628
+ }, []);
1629
+ const timeoutRef = useRef2(null);
1630
+ useEffect14(() => {
1631
+ if (isQualityMenuOpen || isSubtitleMenuOpen) {
1632
+ if (timeoutRef.current) {
1633
+ clearTimeout(timeoutRef.current);
1634
+ }
1635
+ setOpacity("100");
1534
1636
  } else {
1535
- if (onPlay) onPlay(currentTime);
1637
+ if (timeoutRef.current) {
1638
+ clearTimeout(timeoutRef.current);
1639
+ }
1640
+ setOpacity("0");
1641
+ timeoutRef.current = setTimeout(() => {
1642
+ setIsControlBarPresent(false);
1643
+ }, 3e3);
1536
1644
  }
1537
- }
1538
- }, [isPaused, isReady]);
1539
- useEffect14(() => {
1540
- if (isReady) {
1541
- const controlBarTimeout = setTimeout(() => {
1542
- renderControlBar(
1543
- id,
1544
- playerRef.current,
1545
- isPaused,
1546
- setIsPaused,
1547
- duration,
1548
- notes,
1549
- chapters,
1550
- 5,
1551
- handleSaveNoteAction,
1552
- opacity,
1553
- (e) => {
1554
- handlePlayerClick(e, true);
1555
- },
1556
- bgColor,
1557
- setIsQualityMenuOpen,
1558
- setIsSubtitleMenuOpen,
1559
- disableNote
1560
- );
1561
- }, 500);
1562
- return () => clearTimeout(controlBarTimeout);
1563
- }
1564
- }, [
1565
- id,
1566
- playerRef,
1567
- isPaused,
1568
- setIsPaused,
1569
- notes,
1570
- chapters,
1571
- isReady,
1572
- handleSaveNoteAction,
1573
- duration,
1574
- opacity
1575
- ]);
1576
- useEffect14(() => {
1577
- if (isReady) {
1578
- const playButtonTimeout = setTimeout(() => {
1579
- renderBigPlayButton(
1580
- id,
1581
- playerRef.current,
1582
- isPaused,
1583
- setIsPaused,
1584
- opacity
1585
- );
1586
- }, 500);
1587
- return () => clearTimeout(playButtonTimeout);
1588
- }
1589
- }, [id, isPaused, isReady, opacity]);
1590
- useEffect14(() => {
1591
- if (playerRef.current) {
1592
- const intervalId = setInterval(() => {
1593
- if (playerRef.current) setIsPaused(playerRef.current.paused());
1594
- }, 500);
1595
- return () => clearInterval(intervalId);
1596
- }
1597
- }, []);
1598
- useEffect14(() => {
1599
- return () => {
1600
- if (playerRef.current) {
1601
- playerRef.current.dispose();
1602
- playerRef.current = void 0;
1603
- if (bigPlayButtonRoot[id]) {
1604
- bigPlayButtonRoot[id].unmount();
1605
- bigPlayButtonRoot[id] = void 0;
1645
+ }, [isQualityMenuOpen, isSubtitleMenuOpen]);
1646
+ useEffect14(() => {
1647
+ if (isNoteOpen) {
1648
+ if (timeoutRef.current) {
1649
+ clearTimeout(timeoutRef.current);
1606
1650
  }
1607
- if (controlBarRoot[id]) {
1608
- controlBarRoot[id].unmount();
1609
- controlBarRoot[id] = void 0;
1651
+ } else {
1652
+ if (timeoutRef.current) {
1653
+ clearTimeout(timeoutRef.current);
1610
1654
  }
1655
+ setOpacity("0");
1656
+ timeoutRef.current = setTimeout(() => {
1657
+ setIsControlBarPresent(false);
1658
+ }, 3e3);
1611
1659
  }
1612
- };
1613
- }, []);
1614
- const timeoutRef = useRef2(null);
1615
- useEffect14(() => {
1616
- if (isQualityMenuOpen || isSubtitleMenuOpen) {
1660
+ }, [isNoteOpen]);
1661
+ const handlePlayerClick = async (e, isTimerOnly = false) => {
1662
+ e.preventDefault();
1617
1663
  if (timeoutRef.current) {
1618
1664
  clearTimeout(timeoutRef.current);
1619
1665
  }
1620
1666
  setOpacity("100");
1621
- } else {
1622
- if (timeoutRef.current) {
1623
- clearTimeout(timeoutRef.current);
1624
- }
1625
- setOpacity("0");
1667
+ setIsControlBarPresent(true);
1626
1668
  timeoutRef.current = setTimeout(() => {
1669
+ setOpacity("0");
1670
+ setBgColor("transparent");
1627
1671
  setIsControlBarPresent(false);
1628
1672
  }, 3e3);
1629
- }
1630
- }, [isQualityMenuOpen, isSubtitleMenuOpen]);
1631
- const handlePlayerClick = async (e, isTimerOnly = false) => {
1632
- e.preventDefault();
1633
- if (timeoutRef.current) {
1634
- clearTimeout(timeoutRef.current);
1635
- }
1636
- setOpacity("100");
1637
- setIsControlBarPresent(true);
1638
- timeoutRef.current = setTimeout(() => {
1639
- setOpacity("0");
1640
- setBgColor("transparent");
1641
- setIsControlBarPresent(false);
1642
- }, 3e3);
1643
- if (isTimerOnly) {
1644
- return;
1645
- }
1646
- if (!isControlBarPresent) {
1647
- return;
1648
- }
1649
- if (playerRef.current) {
1650
- if (playerRef.current.paused()) {
1651
- try {
1652
- await playerRef.current.play();
1653
- setIsPaused(false);
1654
- } catch (error) {
1655
- console.error("Failed to play video:", error);
1656
- }
1657
- } else {
1658
- playerRef.current.pause();
1659
- setIsPaused(true);
1660
- if (onPause) onPause(playerRef.current.currentTime() || 0);
1673
+ if (isTimerOnly) {
1674
+ return;
1661
1675
  }
1662
- }
1663
- };
1664
- const videoRefs = useRef2(null);
1665
- useEffect14(() => {
1666
- const observer = new IntersectionObserver(
1667
- (entries) => {
1668
- entries.forEach((entry) => {
1669
- var _a2, _b;
1670
- if (entry.isIntersecting === false) {
1671
- if (((_a2 = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _a2.paused()) === false) {
1672
- try {
1673
- (_b = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _b.pause();
1674
- setIsPaused(true);
1675
- } catch (error) {
1676
- console.error("Failed to play video:", error);
1677
- }
1678
- }
1679
- }
1680
- });
1681
- },
1682
- {
1683
- threshold: 0.1
1684
- // The amount of the component that must be visible (0.1 means 10% visible)
1676
+ if (!isControlBarPresent) {
1677
+ return;
1685
1678
  }
1686
- );
1687
- if (videoRefs.current) {
1688
- observer.observe(videoRefs.current);
1689
- }
1690
- return () => {
1691
- if (videoRefs.current) {
1692
- observer.unobserve(videoRef.current);
1693
- }
1694
- };
1695
- }, []);
1696
- const [timeSeeker, setTimeSeeker] = useState13("0");
1697
- useEffect14(() => {
1698
- const updateTimeSeeker = () => {
1699
- var _a2, _b, _c, _d;
1700
- if (playerRef == null ? void 0 : playerRef.current) {
1701
- const currentTime = (_b = (_a2 = playerRef.current) == null ? void 0 : _a2.currentTime) == null ? void 0 : _b.call(_a2);
1702
- const duration2 = (_d = (_c = playerRef.current) == null ? void 0 : _c.duration) == null ? void 0 : _d.call(_c);
1703
- if (duration2 && currentTime !== void 0) {
1704
- const value = `${currentTime / duration2 * 100}%`;
1705
- setTimeSeeker(value);
1679
+ if (playerRef.current) {
1680
+ if (playerRef.current.paused()) {
1681
+ try {
1682
+ await playerRef.current.play();
1683
+ setIsPaused(false);
1684
+ } catch (error) {
1685
+ console.error("Failed to play video:", error);
1686
+ }
1706
1687
  } else {
1707
- setTimeSeeker("0");
1688
+ playerRef.current.pause();
1689
+ setIsPaused(true);
1690
+ if (onPause) onPause(playerRef.current.currentTime() || 0);
1708
1691
  }
1709
1692
  }
1710
1693
  };
1711
- updateTimeSeeker();
1712
- }, [(_a = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _a.currentTime()]);
1713
- return /* @__PURE__ */ jsxs14(
1714
- "div",
1715
- {
1716
- ref: videoRefs,
1717
- id: `video-container-${id}`,
1718
- onMouseMove: () => {
1719
- handlePlayerClick(event, true);
1720
- },
1721
- className: "sb-relative sb-rounded-md sb-overflow-hidden sb-w-full sb-h-full sb-bottom-2 ",
1722
- onMouseEnter: () => setIsHovered(true),
1723
- onMouseLeave: () => setIsHovered(false),
1724
- children: [
1725
- /* @__PURE__ */ jsx35(
1726
- "div",
1727
- {
1728
- className: `sb-h-[3px] sb-transition-opacity sb-duration-500 sb-delay-400 sb-z-10 ease-in-out sb-border-spacing-x-2 sb-absolute sb-bg-[red] sb-bottom-0 ${opacity == "100" ? "sb-opacity-0" : "sb-opacity-100"}`,
1729
- style: {
1730
- width: timeSeeker
1694
+ const videoRefs = useRef2(null);
1695
+ useEffect14(() => {
1696
+ const observer = new IntersectionObserver(
1697
+ (entries) => {
1698
+ entries.forEach((entry) => {
1699
+ var _a2, _b;
1700
+ if (entry.isIntersecting === false) {
1701
+ if (((_a2 = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _a2.paused()) === false) {
1702
+ try {
1703
+ (_b = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _b.pause();
1704
+ setIsPaused(true);
1705
+ } catch (error) {
1706
+ console.error("Failed to play video:", error);
1707
+ }
1708
+ }
1731
1709
  }
1710
+ });
1711
+ },
1712
+ {
1713
+ threshold: 0.1
1714
+ // The amount of the component that must be visible (0.1 means 10% visible)
1715
+ }
1716
+ );
1717
+ if (videoRefs.current) {
1718
+ observer.observe(videoRefs.current);
1719
+ }
1720
+ return () => {
1721
+ if (videoRefs.current) {
1722
+ observer.unobserve(videoRef.current);
1723
+ }
1724
+ };
1725
+ }, []);
1726
+ const [timeSeeker, setTimeSeeker] = useState13("0");
1727
+ useEffect14(() => {
1728
+ const updateTimeSeeker = () => {
1729
+ var _a2, _b, _c, _d;
1730
+ if (playerRef == null ? void 0 : playerRef.current) {
1731
+ const currentTime = (_b = (_a2 = playerRef.current) == null ? void 0 : _a2.currentTime) == null ? void 0 : _b.call(_a2);
1732
+ const duration2 = (_d = (_c = playerRef.current) == null ? void 0 : _c.duration) == null ? void 0 : _d.call(_c);
1733
+ if (duration2 && currentTime !== void 0) {
1734
+ const value = `${currentTime / duration2 * 100}%`;
1735
+ setTimeSeeker(value);
1736
+ } else {
1737
+ setTimeSeeker("0");
1732
1738
  }
1733
- ),
1734
- /* @__PURE__ */ jsx35(
1735
- "div",
1736
- {
1737
- className: "hover:sb-cursor-pointer sb-w-full sb-h-full",
1738
- "data-vjs-player": true,
1739
- children: /* @__PURE__ */ jsx35(
1740
- "div",
1741
- {
1742
- onClick: handlePlayerClick,
1743
- ref: videoRef,
1744
- className: "sb-h-full sb-w-full sb-relative"
1739
+ }
1740
+ };
1741
+ updateTimeSeeker();
1742
+ }, [(_a = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _a.currentTime()]);
1743
+ return /* @__PURE__ */ jsxs14(
1744
+ "div",
1745
+ {
1746
+ ref: videoRefs,
1747
+ id: `video-container-${id}`,
1748
+ onMouseMove: () => {
1749
+ handlePlayerClick(event, true);
1750
+ },
1751
+ className: "sb-relative sb-rounded-md sb-overflow-hidden sb-w-full sb-h-full sb-bottom-2 ",
1752
+ onMouseEnter: () => setIsHovered(true),
1753
+ onMouseLeave: () => setIsHovered(false),
1754
+ children: [
1755
+ /* @__PURE__ */ jsx35(
1756
+ "div",
1757
+ {
1758
+ ref: childRef,
1759
+ onClick: handlePlayerClick,
1760
+ className: `sb-h-[3px] sb-transition-opacity sb-duration-500 sb-delay-400 sb-z-10 ease-in-out sb-border-spacing-x-2 sb-absolute sb-bg-[red] sb-bottom-0 ${opacity == "100" ? "sb-opacity-0" : "sb-opacity-100"}`,
1761
+ style: {
1762
+ width: timeSeeker
1745
1763
  }
1746
- )
1747
- }
1748
- )
1749
- ]
1750
- }
1751
- );
1752
- };
1764
+ }
1765
+ ),
1766
+ /* @__PURE__ */ jsx35(
1767
+ "div",
1768
+ {
1769
+ className: "hover:sb-cursor-pointer sb-w-full sb-h-full",
1770
+ "data-vjs-player": true,
1771
+ children: /* @__PURE__ */ jsx35(
1772
+ "div",
1773
+ {
1774
+ onClick: handlePlayerClick,
1775
+ ref: videoRef,
1776
+ className: "sb-h-full sb-w-full sb-relative"
1777
+ }
1778
+ )
1779
+ }
1780
+ )
1781
+ ]
1782
+ }
1783
+ );
1784
+ }
1785
+ );
1753
1786
  var VideoPlayerComponent_default = VideoPlayerComponent;
1754
1787
 
1755
1788
  // src/components/SoftBuildersVideoPlayer/index.tsx
@@ -1764,69 +1797,73 @@ var DEFAULT_OPTIONS = {
1764
1797
  sources: [],
1765
1798
  tracks: []
1766
1799
  };
1767
- var Component = ({
1768
- options,
1769
- notes,
1770
- chapters,
1771
- startTime = 0,
1772
- handleSaveNoteAction,
1773
- onPlay,
1774
- onPause,
1775
- isFocused = true,
1776
- disableNote
1777
- }) => {
1778
- options = __spreadProps(__spreadValues({}, options), {
1779
- responsive: true,
1780
- inactivityTimeout: 0,
1781
- fullscreen: {
1782
- navigationUI: "hide"
1783
- }
1784
- });
1785
- if (options.autoplay === void 0)
1786
- options.autoplay = DEFAULT_OPTIONS.autoplay;
1787
- if (options.controls === void 0)
1788
- options.controls = DEFAULT_OPTIONS.controls;
1789
- if (options.fluid === void 0) options.fluid = DEFAULT_OPTIONS.fluid;
1790
- if ((options == null ? void 0 : options.muted) === void 0) options.muted = DEFAULT_OPTIONS == null ? void 0 : DEFAULT_OPTIONS.muted;
1791
- if (options.height === void 0) options.height = DEFAULT_OPTIONS.height;
1792
- if (options.width === void 0) options.width = DEFAULT_OPTIONS.width;
1793
- const [tracks, setTracks] = useState14([]);
1794
- useEffect15(() => {
1795
- }, [isFocused]);
1796
- useEffect15(() => {
1797
- const getTracks = async () => {
1798
- const newTracks = [];
1799
- if (Array.isArray(options == null ? void 0 : options.tracks))
1800
- for (const [i, s] of options == null ? void 0 : options.tracks.entries()) {
1801
- let src = s.src;
1802
- if (s.memeType == "text/srt") {
1803
- src = await convertSRTtoVTT(s.src);
1800
+ var Component = forwardRef2(
1801
+ ({
1802
+ options,
1803
+ notes,
1804
+ chapters,
1805
+ startTime = 0,
1806
+ handleSaveNoteAction,
1807
+ onPlay,
1808
+ onPause,
1809
+ isFocused = true,
1810
+ disableNote,
1811
+ childRef
1812
+ }) => {
1813
+ options = __spreadProps(__spreadValues({}, options), {
1814
+ responsive: true,
1815
+ inactivityTimeout: 0,
1816
+ fullscreen: {
1817
+ navigationUI: "hide"
1818
+ }
1819
+ });
1820
+ if (options.autoplay === void 0)
1821
+ options.autoplay = DEFAULT_OPTIONS.autoplay;
1822
+ if (options.controls === void 0)
1823
+ options.controls = DEFAULT_OPTIONS.controls;
1824
+ if (options.fluid === void 0) options.fluid = DEFAULT_OPTIONS.fluid;
1825
+ if ((options == null ? void 0 : options.muted) === void 0) options.muted = DEFAULT_OPTIONS == null ? void 0 : DEFAULT_OPTIONS.muted;
1826
+ if (options.height === void 0) options.height = DEFAULT_OPTIONS.height;
1827
+ if (options.width === void 0) options.width = DEFAULT_OPTIONS.width;
1828
+ const [tracks, setTracks] = useState14([]);
1829
+ useEffect15(() => {
1830
+ }, [isFocused]);
1831
+ useEffect15(() => {
1832
+ const getTracks = async () => {
1833
+ const newTracks = [];
1834
+ if (Array.isArray(options == null ? void 0 : options.tracks))
1835
+ for (const [i, s] of options == null ? void 0 : options.tracks.entries()) {
1836
+ let src = s.src;
1837
+ if (s.memeType == "text/srt") {
1838
+ src = await convertSRTtoVTT(s.src);
1839
+ }
1840
+ newTracks.push(__spreadProps(__spreadValues({}, s), {
1841
+ src
1842
+ }));
1804
1843
  }
1805
- newTracks.push(__spreadProps(__spreadValues({}, s), {
1806
- src
1807
- }));
1808
- }
1809
- setTracks(newTracks);
1810
- };
1811
- getTracks();
1812
- }, [options == null ? void 0 : options.tracks]);
1813
- const id = (Date.now() + Math.random() * 100).toString();
1814
- return /* @__PURE__ */ jsx36(
1815
- VideoPlayerComponent_default,
1816
- {
1817
- id,
1818
- chapters,
1819
- options: __spreadProps(__spreadValues({}, options), { tracks }),
1820
- notes,
1821
- poster: "",
1822
- startTime,
1823
- handleSaveNoteAction,
1824
- disableNote,
1825
- onPause,
1826
- onPlay
1827
- }
1828
- );
1829
- };
1844
+ setTracks(newTracks);
1845
+ };
1846
+ getTracks();
1847
+ }, [options == null ? void 0 : options.tracks]);
1848
+ const id = (Date.now() + Math.random() * 100).toString();
1849
+ return /* @__PURE__ */ jsx36(
1850
+ VideoPlayerComponent_default,
1851
+ {
1852
+ id,
1853
+ chapters,
1854
+ options: __spreadProps(__spreadValues({}, options), { tracks }),
1855
+ notes,
1856
+ poster: "",
1857
+ startTime,
1858
+ handleSaveNoteAction,
1859
+ disableNote,
1860
+ onPause,
1861
+ onPlay,
1862
+ childRef
1863
+ }
1864
+ );
1865
+ }
1866
+ );
1830
1867
  var SoftBuildersVideoPlayer = memo(Component, (prevProps, nextProps) => {
1831
1868
  return prevProps.options === nextProps.options && prevProps.notes === nextProps.notes && prevProps.chapters === nextProps.chapters && prevProps.startTime === nextProps.startTime;
1832
1869
  });