softbuilders-react-video-player 1.1.22 → 1.1.24
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/ControlBar/index.js +10 -8
- package/dist/components/ControlBar/index.js.map +1 -1
- package/dist/components/ControlBar/index.tsx +20 -16
- package/dist/components/MenuButton/index.d.ts +2 -1
- package/dist/components/MenuButton/index.js +5 -2
- package/dist/components/MenuButton/index.js.map +1 -1
- package/dist/components/MenuButton/index.tsx +12 -3
- package/dist/components/QualityMenu/index.d.ts +4 -2
- package/dist/components/QualityMenu/index.js +9 -7
- package/dist/components/QualityMenu/index.js.map +1 -1
- package/dist/components/QualityMenu/index.tsx +33 -8
- package/dist/components/SoftBuildersVideoPlayer/index.d.ts +2 -1
- package/dist/components/SoftBuildersVideoPlayer/index.js +4 -1
- package/dist/components/SoftBuildersVideoPlayer/index.js.map +1 -1
- package/dist/components/SoftBuildersVideoPlayer/index.tsx +5 -1
- package/dist/components/SubtitleMenu/index.d.ts +4 -2
- package/dist/components/SubtitleMenu/index.js +8 -3
- package/dist/components/SubtitleMenu/index.js.map +1 -1
- package/dist/components/SubtitleMenu/index.tsx +19 -4
- package/dist/components/VideoPlayerComponent/index.js +70 -8
- package/dist/components/VideoPlayerComponent/index.js.map +1 -1
- package/dist/components/VideoPlayerComponent/index.tsx +80 -7
- package/dist/components/VideoPlayerComponent/style/style.css +1 -0
- package/dist/components/VolumeSlider/index.js +12 -3
- package/dist/components/VolumeSlider/index.js.map +1 -1
- package/dist/components/VolumeSlider/index.tsx +20 -6
- package/dist/index.css +35 -11
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +295 -158
- package/dist/styles/tailwind.css +34 -11
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -154,7 +154,7 @@ var CurrentTimeLabel = ({}) => {
|
|
154
154
|
var CurrentTimeLabel_default = CurrentTimeLabel;
|
155
155
|
|
156
156
|
// src/components/VolumeSlider/index.tsx
|
157
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
157
|
+
import React2, { useEffect as useEffect2, useState as useState2 } from "react";
|
158
158
|
|
159
159
|
// src/components/Slider/index.tsx
|
160
160
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
@@ -517,11 +517,18 @@ var VolumeSlider = ({ width = 0, setIsSeeking }) => {
|
|
517
517
|
useEffect2(() => {
|
518
518
|
setVolume((player == null ? void 0 : player.muted()) ? 0 : Number(player == null ? void 0 : player.volume()) * 100 || 0);
|
519
519
|
}, [player]);
|
520
|
+
const timeoutRef = React2.useRef(null);
|
520
521
|
const toggleVisiblity = (e) => {
|
521
522
|
e.preventDefault();
|
522
523
|
e.stopPropagation();
|
523
524
|
setIsSeeking(isVisible);
|
525
|
+
if (timeoutRef.current) {
|
526
|
+
clearTimeout(timeoutRef.current);
|
527
|
+
}
|
524
528
|
setVisible((prev) => !prev);
|
529
|
+
timeoutRef.current = setTimeout(() => {
|
530
|
+
setVisible(false);
|
531
|
+
}, 5e3);
|
525
532
|
};
|
526
533
|
const handleValueChange = (e) => {
|
527
534
|
e.preventDefault();
|
@@ -538,12 +545,12 @@ var VolumeSlider = ({ width = 0, setIsSeeking }) => {
|
|
538
545
|
return /* @__PURE__ */ jsxs4(
|
539
546
|
"div",
|
540
547
|
{
|
541
|
-
className: `sb-flex ${isVisible ? "" : "-sb-ml-2"} sb-flex-col-reverse ${false ? "!sb-flex-row !sb-items-
|
548
|
+
className: `sb-flex ${isVisible ? "" : "-sb-ml-2"} ${width > 400 ? "sb-flex-col-reverse " : "sb-flex-col !sb-justify-start"} ${false ? "!sb-flex-row !sb-items-start " : ""} sb-items-center sb-gap-1 sb-h-full`,
|
542
549
|
children: [
|
543
550
|
/* @__PURE__ */ jsx19(
|
544
551
|
"div",
|
545
552
|
{
|
546
|
-
className: `sb-flex sb-relative ${width < 400 ? "" : "
|
553
|
+
className: `sb-flex sb-relative ${width < 400 ? "-sb-top-1" : "sb-top-1"} `,
|
547
554
|
onClick: toggleVisiblity,
|
548
555
|
children: volume === 0 || (player == null ? void 0 : player.muted()) ? /* @__PURE__ */ jsx19(
|
549
556
|
MuteIcon_default,
|
@@ -561,7 +568,7 @@ var VolumeSlider = ({ width = 0, setIsSeeking }) => {
|
|
561
568
|
/* @__PURE__ */ jsx19("div", { className: "sb-flex sb-items-center sb-justify-center", children: /* @__PURE__ */ jsx19(
|
562
569
|
"div",
|
563
570
|
{
|
564
|
-
className: `sb-transition-all sb-ease-in-out sb-duration-500 ${isVisible ? "sb-w-[22px] sb-opacity-100 sb-visible" : "sb-w-0 sb-opacity-0 sb-invisible"} -sb-rotate-90 -sb-translate-y-1 sb-relative ${false ? "sb-static sb-w-16 sb-rotate-0 sb-translate-y-0 " : ""}`,
|
571
|
+
className: `sb-transition-all sb-ease-in-out sb-duration-500 ${isVisible ? "sb-w-[22px] sb-opacity-100 sb-visible" : "sb-w-0 sb-opacity-0 sb-invisible"} ${width > 400 ? "-sb-rotate-90 -sb-translate-y-1" : "sb-rotate-90 sb-translate-y-1"} sb-relative ${false ? "sb-static sb-w-16 sb-rotate-0 sb-translate-y-0 " : ""}`,
|
565
572
|
children: /* @__PURE__ */ jsx19(
|
566
573
|
Slider_default,
|
567
574
|
{
|
@@ -586,7 +593,12 @@ import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
586
593
|
// src/components/MenuButton/index.tsx
|
587
594
|
import { useCallback, useEffect as useEffect3, useRef, useState as useState3 } from "react";
|
588
595
|
import { jsx as jsx20, jsxs as jsxs5 } from "react/jsx-runtime";
|
589
|
-
var MenuButton = ({
|
596
|
+
var MenuButton = ({
|
597
|
+
buttonContent,
|
598
|
+
menuContent,
|
599
|
+
close,
|
600
|
+
classContainer
|
601
|
+
}) => {
|
590
602
|
const [isOpen, setIsOpen] = useState3(false);
|
591
603
|
const buttonRef = useRef(null);
|
592
604
|
const menuRef = useRef(null);
|
@@ -611,7 +623,10 @@ var MenuButton = ({ buttonContent, menuContent, close }) => {
|
|
611
623
|
"button",
|
612
624
|
{
|
613
625
|
ref: buttonRef,
|
614
|
-
onClick:
|
626
|
+
onClick: (e) => {
|
627
|
+
e.stopPropagation();
|
628
|
+
toggleMenu();
|
629
|
+
},
|
615
630
|
"aria-haspopup": "true",
|
616
631
|
"aria-expanded": isOpen,
|
617
632
|
"aria-label": "Open menu",
|
@@ -625,7 +640,7 @@ var MenuButton = ({ buttonContent, menuContent, close }) => {
|
|
625
640
|
role: "menu",
|
626
641
|
"aria-orientation": "vertical",
|
627
642
|
"aria-labelledby": "Open menu",
|
628
|
-
className:
|
643
|
+
className: `sb-absolute sb-shadow-lg sb-right-0 sb-bottom-10 ${classContainer}`,
|
629
644
|
children: menuContent
|
630
645
|
}
|
631
646
|
)
|
@@ -638,14 +653,27 @@ import { jsx as jsx21, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
638
653
|
var QualityOption = ({
|
639
654
|
isSelected,
|
640
655
|
quality,
|
641
|
-
onClick
|
656
|
+
onClick,
|
657
|
+
width
|
642
658
|
}) => {
|
643
|
-
return /* @__PURE__ */ jsx21(
|
644
|
-
|
645
|
-
|
646
|
-
|
659
|
+
return /* @__PURE__ */ jsx21(
|
660
|
+
"button",
|
661
|
+
{
|
662
|
+
className: `hover:sb-text-orange-500 ${width > 400 ? "sb-p-2" : "sp-pb-1"}`,
|
663
|
+
onClick,
|
664
|
+
children: /* @__PURE__ */ jsxs6("div", { className: "sb-grid sb-grid-cols-12 sb-items-center sb-gap-2", children: [
|
665
|
+
/* @__PURE__ */ jsx21("div", { className: "sb-col-span-3", children: isSelected ? /* @__PURE__ */ jsx21(
|
666
|
+
CheckedIcon_default,
|
667
|
+
{
|
668
|
+
className: `${width > 400 ? "sb-w-5 sb-h-5" : "sb-w-3 sb-h-3"}`
|
669
|
+
}
|
670
|
+
) : /* @__PURE__ */ jsx21("div", {}) }),
|
671
|
+
/* @__PURE__ */ jsx21("p", { className: "sb-text-left sb-col-span-9", children: quality.label })
|
672
|
+
] })
|
673
|
+
}
|
674
|
+
);
|
647
675
|
};
|
648
|
-
var QualityMenu = ({}) => {
|
676
|
+
var QualityMenu = ({ width }) => {
|
649
677
|
const { player } = useSoftBuildersVideoPlayerContext();
|
650
678
|
const [closeMenuFunction, setCloseMenuFunction] = useState4(void 0);
|
651
679
|
const [qualities, setQualities] = useState4(
|
@@ -654,12 +682,12 @@ var QualityMenu = ({}) => {
|
|
654
682
|
const [currentQualitySrc, setCurrentQualitySrc] = useState4(void 0);
|
655
683
|
useEffect4(() => {
|
656
684
|
if (player) {
|
657
|
-
const sources = player.currentSources();
|
685
|
+
const sources = player == null ? void 0 : player.currentSources();
|
658
686
|
const qs = JSON.parse(
|
659
687
|
JSON.stringify(sources)
|
660
688
|
);
|
661
689
|
setQualities(qs);
|
662
|
-
const source = player.currentSource();
|
690
|
+
const source = player == null ? void 0 : player.currentSource();
|
663
691
|
const quality = JSON.parse(
|
664
692
|
JSON.stringify(source)
|
665
693
|
);
|
@@ -669,47 +697,61 @@ var QualityMenu = ({}) => {
|
|
669
697
|
return /* @__PURE__ */ jsx21(
|
670
698
|
MenuButton_default,
|
671
699
|
{
|
700
|
+
classContainer: `${width < 400 ? "!sb-top-8 -sb-left-9" : ""}`,
|
672
701
|
buttonContent: /* @__PURE__ */ jsx21(SettingsIcon_default, { className: "sb-w-3 sb-h-3" }),
|
673
|
-
menuContent: /* @__PURE__ */ jsx21(
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
const source = qualities.find(
|
698
|
-
(_q) => q.label == _q.label
|
699
|
-
);
|
700
|
-
if (source && source.src != currentQualitySrc) {
|
701
|
-
player == null ? void 0 : player.src(source.src);
|
702
|
-
const currentTime = player == null ? void 0 : player.currentTime();
|
703
|
-
setCurrentQualitySrc(source.src);
|
704
|
-
player == null ? void 0 : player.currentTime(currentTime);
|
705
|
-
player == null ? void 0 : player.play();
|
706
|
-
}
|
702
|
+
menuContent: /* @__PURE__ */ jsx21(
|
703
|
+
"div",
|
704
|
+
{
|
705
|
+
className: `sb-rounded-md sb-bg-[#303030] sb-bg-opacity-50 ${width > 400 ? "sb-w-[150px] sb-py-5" : "sb-w-[90px] sb-items-center sb-justify-center sb-py-1"}`,
|
706
|
+
children: /* @__PURE__ */ jsxs6("div", { className: "sb-flex sb-flex-col sb-gap-3", children: [
|
707
|
+
/* @__PURE__ */ jsxs6(
|
708
|
+
"div",
|
709
|
+
{
|
710
|
+
className: `sb-px-5 sb-flex sb-flex-row sb-gap-3 sb-items-start sb-relative sb-top-2`,
|
711
|
+
children: [
|
712
|
+
/* @__PURE__ */ jsx21(
|
713
|
+
"button",
|
714
|
+
{
|
715
|
+
onClick: () => {
|
716
|
+
if (closeMenuFunction) {
|
717
|
+
closeMenuFunction();
|
718
|
+
}
|
719
|
+
},
|
720
|
+
className: "hover:sb-scale-150",
|
721
|
+
children: /* @__PURE__ */ jsx21(LeftArrowIcon_default, { className: "sb-w-3 sb-h-3" })
|
722
|
+
}
|
723
|
+
),
|
724
|
+
/* @__PURE__ */ jsx21("h3", { children: "Quality" })
|
725
|
+
]
|
707
726
|
}
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
727
|
+
),
|
728
|
+
/* @__PURE__ */ jsx21("div", { className: "sb-w-full sb-h-[.1px] sb-bg-[#AAAAAA] sb-bg-opacity-70" }),
|
729
|
+
/* @__PURE__ */ jsx21("div", { className: "sb-px-5 sb-flex sb-flex-col sb-gap-3 sb-items-start ", children: qualities.map((q, i) => {
|
730
|
+
return /* @__PURE__ */ jsx21(
|
731
|
+
QualityOption,
|
732
|
+
{
|
733
|
+
width,
|
734
|
+
isSelected: currentQualitySrc === q.src,
|
735
|
+
quality: q,
|
736
|
+
onClick: () => {
|
737
|
+
const source = qualities.find(
|
738
|
+
(_q) => q.label == _q.label
|
739
|
+
);
|
740
|
+
if (source && source.src != currentQualitySrc) {
|
741
|
+
player == null ? void 0 : player.src(source.src);
|
742
|
+
const currentTime = player == null ? void 0 : player.currentTime();
|
743
|
+
setCurrentQualitySrc(source.src);
|
744
|
+
player == null ? void 0 : player.currentTime(currentTime);
|
745
|
+
player == null ? void 0 : player.play();
|
746
|
+
}
|
747
|
+
}
|
748
|
+
},
|
749
|
+
`quality-${q.label}-${i}`
|
750
|
+
);
|
751
|
+
}) })
|
752
|
+
] })
|
753
|
+
}
|
754
|
+
),
|
713
755
|
close: (fn) => {
|
714
756
|
setCloseMenuFunction(() => fn);
|
715
757
|
}
|
@@ -1046,12 +1088,22 @@ var SubtitleOption = ({
|
|
1046
1088
|
subtitle,
|
1047
1089
|
onClick
|
1048
1090
|
}) => {
|
1049
|
-
return /* @__PURE__ */ jsx32(
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1091
|
+
return /* @__PURE__ */ jsx32(
|
1092
|
+
"button",
|
1093
|
+
{
|
1094
|
+
className: "hover:sb-text-orange-500 sb-p-2",
|
1095
|
+
onClick: (e) => {
|
1096
|
+
e.stopPropagation();
|
1097
|
+
onClick();
|
1098
|
+
},
|
1099
|
+
children: /* @__PURE__ */ jsxs12("div", { className: "sb-grid sb-grid-cols-12 sb-items-center sb-gap-2", children: [
|
1100
|
+
/* @__PURE__ */ jsx32("div", { className: "sb-col-span-3", children: isSelected ? /* @__PURE__ */ jsx32(CheckedIcon_default, { className: "sb-w-5 sb-h-5" }) : /* @__PURE__ */ jsx32("div", {}) }),
|
1101
|
+
/* @__PURE__ */ jsx32("p", { className: "sb-text-left sb-col-span-9", children: subtitle.label })
|
1102
|
+
] })
|
1103
|
+
}
|
1104
|
+
);
|
1053
1105
|
};
|
1054
|
-
var SubtitleMenu = ({}) => {
|
1106
|
+
var SubtitleMenu = ({ width }) => {
|
1055
1107
|
const { player } = useSoftBuildersVideoPlayerContext();
|
1056
1108
|
const [closeMenuFunction, setCloseMenuFunction] = useState11(void 0);
|
1057
1109
|
const [subtitles, setSubtitles] = useState11([]);
|
@@ -1076,38 +1128,45 @@ var SubtitleMenu = ({}) => {
|
|
1076
1128
|
return /* @__PURE__ */ jsx32(
|
1077
1129
|
MenuButton_default,
|
1078
1130
|
{
|
1131
|
+
classContainer: `${width < 400 ? "!sb-top-8 -sb-left-9" : ""}`,
|
1079
1132
|
buttonContent: /* @__PURE__ */ jsx32(SubIcon_default, { className: "sb-w-4 sb-h-4 sb-text-white " }),
|
1080
|
-
menuContent: /* @__PURE__ */ jsx32(
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1133
|
+
menuContent: /* @__PURE__ */ jsx32(
|
1134
|
+
"div",
|
1135
|
+
{
|
1136
|
+
className: `sb-rounded-md sb-bg-[#303030] sb-bg-opacity-50 ${width > 400 ? "sb-w-[150px] sb-py-5" : "sb-w-[90px] sb-items-center sb-justify-center sb-py-1"}`,
|
1137
|
+
children: /* @__PURE__ */ jsxs12("div", { className: "sb-flex sb-flex-col sb-gap-3", children: [
|
1138
|
+
/* @__PURE__ */ jsxs12("div", { className: "sb-px-5 sb-flex sb-flex-row sb-gap-3 sb-items-start", children: [
|
1139
|
+
/* @__PURE__ */ jsx32(
|
1140
|
+
"button",
|
1141
|
+
{
|
1142
|
+
onClick: () => {
|
1143
|
+
if (closeMenuFunction) {
|
1144
|
+
closeMenuFunction();
|
1145
|
+
}
|
1146
|
+
},
|
1147
|
+
className: "hover:sb-scale-150",
|
1148
|
+
children: /* @__PURE__ */ jsx32(LeftArrowIcon_default, { className: "sb-w-3 sb-h-3" })
|
1088
1149
|
}
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
}
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
}) })
|
1110
|
-
] }) }),
|
1150
|
+
),
|
1151
|
+
/* @__PURE__ */ jsx32("h3", { children: "Subtitle" })
|
1152
|
+
] }),
|
1153
|
+
/* @__PURE__ */ jsx32("div", { className: "sb-w-full sb-h-[.1px] sb-bg-[#AAAAAA] sb-bg-opacity-70" }),
|
1154
|
+
/* @__PURE__ */ jsx32("div", { className: "sb-px-5 sb-flex sb-flex-col sb-gap-3 sb-items-start", children: subtitles.map((q, i) => {
|
1155
|
+
return /* @__PURE__ */ jsx32(
|
1156
|
+
SubtitleOption,
|
1157
|
+
{
|
1158
|
+
isSelected: q.mode === "showing",
|
1159
|
+
subtitle: q,
|
1160
|
+
onClick: () => {
|
1161
|
+
handleSelectSubtitle(q);
|
1162
|
+
}
|
1163
|
+
},
|
1164
|
+
`subtitle-${q.label}-${i}`
|
1165
|
+
);
|
1166
|
+
}) })
|
1167
|
+
] })
|
1168
|
+
}
|
1169
|
+
),
|
1111
1170
|
close: (fn) => {
|
1112
1171
|
setCloseMenuFunction(() => fn);
|
1113
1172
|
}
|
@@ -1160,70 +1219,79 @@ var ControlBar = ({
|
|
1160
1219
|
useEffect13(() => {
|
1161
1220
|
setDuration(duration);
|
1162
1221
|
}, [duration]);
|
1163
|
-
return /* @__PURE__ */ jsxs13(
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
onClick: (
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1222
|
+
return /* @__PURE__ */ jsxs13(
|
1223
|
+
"div",
|
1224
|
+
{
|
1225
|
+
className: ` sb-px-2 sb-flex sb-pt-2 sb-justify-center sb-gap-3 sb-w-full sb-h-full ${width > 400 ? "sb-items-end" : "sb-items-start"} sb-pb-2`,
|
1226
|
+
children: [
|
1227
|
+
/* @__PURE__ */ jsx33(BufferTracker_default, {}),
|
1228
|
+
/* @__PURE__ */ jsx33(CurrentTimeTracker_default, {}),
|
1229
|
+
/* @__PURE__ */ jsx33(
|
1230
|
+
"button",
|
1231
|
+
{
|
1232
|
+
onClick: () => {
|
1233
|
+
seek(-seekStep);
|
1234
|
+
},
|
1235
|
+
children: /* @__PURE__ */ jsx33(BackwardIcon_default, { className: "sb-w-3 sb-h-3" })
|
1236
|
+
}
|
1237
|
+
),
|
1238
|
+
/* @__PURE__ */ jsx33("button", { onClick: togglePlay, children: isPaused ? /* @__PURE__ */ jsx33(PlayIcon_default, { className: "sb-w-3 sb-h-3" }) : /* @__PURE__ */ jsx33(PauseIcon_default, { className: "sb-w-3 sb-h-3" }) }),
|
1239
|
+
/* @__PURE__ */ jsx33(
|
1240
|
+
"button",
|
1241
|
+
{
|
1242
|
+
onClick: (e) => {
|
1243
|
+
e.preventDefault();
|
1244
|
+
seek(seekStep);
|
1245
|
+
},
|
1246
|
+
children: /* @__PURE__ */ jsx33(ForwardIcon_default, { className: "sb-w-3 sb-h-3" })
|
1247
|
+
}
|
1248
|
+
),
|
1249
|
+
// isSeeking ||
|
1250
|
+
// width > 400 &&
|
1251
|
+
/* @__PURE__ */ jsx33(
|
1191
1252
|
"div",
|
1192
1253
|
{
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1254
|
+
className: `${width < 400 ? "sb-w-[100px] sb-ml-0 sb-mr-0" : "sb-w-full"}`,
|
1255
|
+
children: /* @__PURE__ */ jsxs13(
|
1256
|
+
"div",
|
1257
|
+
{
|
1258
|
+
style: width < 400 ? {
|
1259
|
+
width: `${width * 0.9}px`,
|
1260
|
+
left: "5%",
|
1261
|
+
top: "90%"
|
1262
|
+
} : { width: "100%" },
|
1263
|
+
className: `flex gap-2 ${width < 400 ? "absolute sb-top-1" : "-sb-translate-y-0 sb-w-full"} hover:sb-w-[45%] sb-transition-all sb-ease-in-out sb-duration-500`,
|
1264
|
+
children: [
|
1265
|
+
/* @__PURE__ */ jsx33(CurrentTimeLabel_default, {}),
|
1266
|
+
/* @__PURE__ */ jsx33(TimeSliderContainer_default, { chapters, notes }),
|
1267
|
+
/* @__PURE__ */ jsx33("p", { children: durationFormater(duration) })
|
1268
|
+
]
|
1269
|
+
}
|
1270
|
+
)
|
1203
1271
|
}
|
1204
|
-
)
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1272
|
+
),
|
1273
|
+
/* @__PURE__ */ jsx33("div", { className: "sb-h-full", children: /* @__PURE__ */ jsx33(VolumeSlider_default, { width, setIsSeeking: (val) => setIsSeeking(val) }) }),
|
1274
|
+
/* @__PURE__ */ jsx33(QualityMenu_default, { width }),
|
1275
|
+
handleSaveNoteAction && /* @__PURE__ */ jsx33(CreateNoteMenu_default, { handleSaveNoteAction }),
|
1276
|
+
/* @__PURE__ */ jsx33(SubtitleMenu_default, { width }),
|
1277
|
+
/* @__PURE__ */ jsx33(
|
1278
|
+
"button",
|
1279
|
+
{
|
1280
|
+
onClick: (e) => {
|
1281
|
+
e.preventDefault();
|
1282
|
+
e.stopPropagation();
|
1283
|
+
if (player == null ? void 0 : player.isFullscreen()) {
|
1284
|
+
player == null ? void 0 : player.exitFullscreen();
|
1285
|
+
} else {
|
1286
|
+
player == null ? void 0 : player.requestFullscreen();
|
1287
|
+
}
|
1288
|
+
},
|
1289
|
+
children: /* @__PURE__ */ jsx33(FullScreenIcon_default, { className: "sb-w-3 sb-h-3" })
|
1219
1290
|
}
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
handleSaveNoteAction && /* @__PURE__ */ jsx33(CreateNoteMenu_default, { handleSaveNoteAction }),
|
1225
|
-
/* @__PURE__ */ jsx33(SubtitleMenu_default, {})
|
1226
|
-
] });
|
1291
|
+
)
|
1292
|
+
]
|
1293
|
+
}
|
1294
|
+
);
|
1227
1295
|
};
|
1228
1296
|
var ControlBar_default = ControlBar;
|
1229
1297
|
|
@@ -1271,7 +1339,7 @@ var renderBigPlayButton = (id, player, isPaused, setIsPaused) => {
|
|
1271
1339
|
}
|
1272
1340
|
};
|
1273
1341
|
var controlBarRoot = {};
|
1274
|
-
var renderControlBar = (id, player, isPaused, setIsPaused, duration, notes, chapters, seekStep = 5, handleSaveNoteAction) => {
|
1342
|
+
var renderControlBar = (id, player, isPaused, setIsPaused, duration, notes, chapters, seekStep = 5, handleSaveNoteAction, opacity = "0") => {
|
1275
1343
|
const container = document.getElementById(`video-container-${id}`);
|
1276
1344
|
if (container) {
|
1277
1345
|
const element = container.querySelector(".vjs-control-bar");
|
@@ -1280,6 +1348,7 @@ var renderControlBar = (id, player, isPaused, setIsPaused, duration, notes, chap
|
|
1280
1348
|
controlBarRoot[id] = ReactDOM.createRoot(element);
|
1281
1349
|
}
|
1282
1350
|
element.style.display = "flex";
|
1351
|
+
element.style.opacity = opacity;
|
1283
1352
|
element.style.height = "100%";
|
1284
1353
|
element.style.alignItems = "flex-end";
|
1285
1354
|
controlBarRoot[id].render(
|
@@ -1317,11 +1386,12 @@ var VideoPlayerComponent = ({
|
|
1317
1386
|
const [isReady, setIsReady] = useState13(false);
|
1318
1387
|
const [isPaused, setIsPaused] = useState13(!options.autoplay);
|
1319
1388
|
const [duration, setDuration] = useState13(1);
|
1389
|
+
const [opacity, setOpacity] = useState13("0");
|
1320
1390
|
const onReady = (player) => {
|
1321
1391
|
if (playerRef) {
|
1322
1392
|
playerRef.current = player;
|
1323
1393
|
setIsReady(true);
|
1324
|
-
player.currentTime(startTime);
|
1394
|
+
player == null ? void 0 : player.currentTime(startTime);
|
1325
1395
|
player.on("waiting", () => {
|
1326
1396
|
});
|
1327
1397
|
player.on("dispose", () => {
|
@@ -1337,6 +1407,7 @@ var VideoPlayerComponent = ({
|
|
1337
1407
|
useEffect14(() => {
|
1338
1408
|
if (!playerRef.current) {
|
1339
1409
|
const videoElement = document.createElement("video-js");
|
1410
|
+
videoElement.setAttribute("playsinline", "true");
|
1340
1411
|
videoElement.classList.add("vjs-big-play-centered");
|
1341
1412
|
if (poster) {
|
1342
1413
|
videoElement.setAttribute("poster", poster);
|
@@ -1385,7 +1456,8 @@ var VideoPlayerComponent = ({
|
|
1385
1456
|
notes,
|
1386
1457
|
chapters,
|
1387
1458
|
5,
|
1388
|
-
handleSaveNoteAction
|
1459
|
+
handleSaveNoteAction,
|
1460
|
+
opacity
|
1389
1461
|
);
|
1390
1462
|
}, 500);
|
1391
1463
|
return () => clearTimeout(controlBarTimeout);
|
@@ -1399,7 +1471,8 @@ var VideoPlayerComponent = ({
|
|
1399
1471
|
chapters,
|
1400
1472
|
isReady,
|
1401
1473
|
handleSaveNoteAction,
|
1402
|
-
duration
|
1474
|
+
duration,
|
1475
|
+
opacity
|
1403
1476
|
]);
|
1404
1477
|
useEffect14(() => {
|
1405
1478
|
if (isReady) {
|
@@ -1417,13 +1490,40 @@ var VideoPlayerComponent = ({
|
|
1417
1490
|
return () => clearInterval(intervalId);
|
1418
1491
|
}
|
1419
1492
|
}, []);
|
1420
|
-
|
1493
|
+
useEffect14(() => {
|
1494
|
+
return () => {
|
1495
|
+
if (playerRef.current) {
|
1496
|
+
playerRef.current.dispose();
|
1497
|
+
playerRef.current = void 0;
|
1498
|
+
if (bigPlayButtonRoot[id]) {
|
1499
|
+
bigPlayButtonRoot[id].unmount();
|
1500
|
+
bigPlayButtonRoot[id] = void 0;
|
1501
|
+
}
|
1502
|
+
if (controlBarRoot[id]) {
|
1503
|
+
controlBarRoot[id].unmount();
|
1504
|
+
controlBarRoot[id] = void 0;
|
1505
|
+
}
|
1506
|
+
}
|
1507
|
+
};
|
1508
|
+
}, []);
|
1509
|
+
const timeoutRef = useRef2(null);
|
1510
|
+
const handlePlayerClick = async (e) => {
|
1421
1511
|
e.preventDefault();
|
1422
|
-
|
1512
|
+
if (timeoutRef.current) {
|
1513
|
+
clearTimeout(timeoutRef.current);
|
1514
|
+
}
|
1515
|
+
setOpacity("100");
|
1516
|
+
timeoutRef.current = setTimeout(() => {
|
1517
|
+
setOpacity("0");
|
1518
|
+
}, 5e3);
|
1423
1519
|
if (playerRef.current) {
|
1424
1520
|
if (playerRef.current.paused()) {
|
1425
|
-
|
1426
|
-
|
1521
|
+
try {
|
1522
|
+
await playerRef.current.play();
|
1523
|
+
setIsPaused(false);
|
1524
|
+
} catch (error) {
|
1525
|
+
console.error("Failed to play video:", error);
|
1526
|
+
}
|
1427
1527
|
} else {
|
1428
1528
|
playerRef.current.pause();
|
1429
1529
|
setIsPaused(true);
|
@@ -1431,9 +1531,42 @@ var VideoPlayerComponent = ({
|
|
1431
1531
|
}
|
1432
1532
|
}
|
1433
1533
|
};
|
1534
|
+
const videoRefs = useRef2(null);
|
1535
|
+
useEffect14(() => {
|
1536
|
+
const observer = new IntersectionObserver(
|
1537
|
+
(entries) => {
|
1538
|
+
entries.forEach((entry) => {
|
1539
|
+
var _a, _b;
|
1540
|
+
if (entry.isIntersecting === false) {
|
1541
|
+
if (((_a = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _a.paused()) === false) {
|
1542
|
+
try {
|
1543
|
+
(_b = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _b.pause();
|
1544
|
+
setIsPaused(true);
|
1545
|
+
} catch (error) {
|
1546
|
+
console.error("Failed to play video:", error);
|
1547
|
+
}
|
1548
|
+
}
|
1549
|
+
}
|
1550
|
+
});
|
1551
|
+
},
|
1552
|
+
{
|
1553
|
+
threshold: 0.1
|
1554
|
+
// The amount of the component that must be visible (0.1 means 10% visible)
|
1555
|
+
}
|
1556
|
+
);
|
1557
|
+
if (videoRefs.current) {
|
1558
|
+
observer.observe(videoRefs.current);
|
1559
|
+
}
|
1560
|
+
return () => {
|
1561
|
+
if (videoRefs.current) {
|
1562
|
+
observer.unobserve(videoRef.current);
|
1563
|
+
}
|
1564
|
+
};
|
1565
|
+
}, []);
|
1434
1566
|
return /* @__PURE__ */ jsx35(
|
1435
1567
|
"div",
|
1436
1568
|
{
|
1569
|
+
ref: videoRefs,
|
1437
1570
|
id: `video-container-${id}`,
|
1438
1571
|
className: "sb-relative sb-rounded-md sb-overflow-hidden",
|
1439
1572
|
children: /* @__PURE__ */ jsx35(
|
@@ -1473,7 +1606,8 @@ var Component = ({
|
|
1473
1606
|
startTime = 0,
|
1474
1607
|
handleSaveNoteAction,
|
1475
1608
|
onPlay,
|
1476
|
-
onPause
|
1609
|
+
onPause,
|
1610
|
+
isFocused = true
|
1477
1611
|
}) => {
|
1478
1612
|
options = __spreadProps(__spreadValues({}, options), {
|
1479
1613
|
responsive: true,
|
@@ -1491,6 +1625,9 @@ var Component = ({
|
|
1491
1625
|
if (options.height === void 0) options.height = DEFAULT_OPTIONS.height;
|
1492
1626
|
if (options.width === void 0) options.width = DEFAULT_OPTIONS.width;
|
1493
1627
|
const [tracks, setTracks] = useState14([]);
|
1628
|
+
useEffect15(() => {
|
1629
|
+
console.log(isFocused, "isF");
|
1630
|
+
}, [isFocused]);
|
1494
1631
|
useEffect15(() => {
|
1495
1632
|
const getTracks = async () => {
|
1496
1633
|
const newTracks = [];
|