@codenkay/video-nsgplayer-ui 4.0.0 → 5.1.0
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/CHANGELOG.md +23 -0
- package/README.md +8 -0
- package/dist/index.cjs +646 -208
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -21
- package/dist/index.d.ts +72 -21
- package/dist/index.js +643 -206
- package/dist/index.js.map +1 -1
- package/dist/player-ui.css +108 -0
- package/package.json +5 -5
- package/styles.css +108 -0
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
QUALITY_PREFERENCE_STORAGE_KEY: () => QUALITY_PREFERENCE_STORAGE_KEY,
|
|
36
36
|
QualitySelector: () => QualitySelector,
|
|
37
37
|
SeekBar: () => SeekBar,
|
|
38
|
+
SettingsMenu: () => SettingsMenu,
|
|
38
39
|
TextTrackSelector: () => TextTrackSelector,
|
|
39
40
|
ZOOM_STEPS: () => ZOOM_STEPS,
|
|
40
41
|
formatPlaybackTime: () => formatPlaybackTime,
|
|
@@ -55,12 +56,12 @@ __export(index_exports, {
|
|
|
55
56
|
module.exports = __toCommonJS(index_exports);
|
|
56
57
|
|
|
57
58
|
// src/NsgVideoPlayerWithControls.tsx
|
|
58
|
-
var
|
|
59
|
+
var import_react9 = require("react");
|
|
59
60
|
var import_video_nsgplayer_core2 = require("@codenkay/video-nsgplayer-core");
|
|
60
61
|
var import_video_nsgplayer_react = require("@codenkay/video-nsgplayer-react");
|
|
61
62
|
|
|
62
63
|
// src/components/PlayerChrome.tsx
|
|
63
|
-
var
|
|
64
|
+
var import_react7 = require("react");
|
|
64
65
|
|
|
65
66
|
// src/hooks/usePlayerControls.ts
|
|
66
67
|
var import_react = require("react");
|
|
@@ -113,6 +114,7 @@ function snapPlaybackRate(rate, visible) {
|
|
|
113
114
|
function resolvePlayerOverlay(input) {
|
|
114
115
|
if (!input.showControls) return "none";
|
|
115
116
|
if (!input.isPlaying) return "play";
|
|
117
|
+
if (input.mediaMode === "audio") return "return-video";
|
|
116
118
|
if (input.muted || input.volume <= 0) return "unmute";
|
|
117
119
|
return "none";
|
|
118
120
|
}
|
|
@@ -404,6 +406,9 @@ function usePlayerControls(options) {
|
|
|
404
406
|
const zoomOut = (0, import_react.useCallback)(() => {
|
|
405
407
|
setZoom((prev) => nextZoom(prev, -1));
|
|
406
408
|
}, []);
|
|
409
|
+
const setZoomLevel = (0, import_react.useCallback)((level) => {
|
|
410
|
+
setZoom(ZOOM_STEPS.includes(level) ? level : 1);
|
|
411
|
+
}, []);
|
|
407
412
|
return {
|
|
408
413
|
isPlaying,
|
|
409
414
|
currentTime,
|
|
@@ -437,7 +442,8 @@ function usePlayerControls(options) {
|
|
|
437
442
|
toggleFullscreen,
|
|
438
443
|
goToLive,
|
|
439
444
|
zoomIn,
|
|
440
|
-
zoomOut
|
|
445
|
+
zoomOut,
|
|
446
|
+
setZoom: setZoomLevel
|
|
441
447
|
};
|
|
442
448
|
}
|
|
443
449
|
|
|
@@ -465,43 +471,53 @@ function PlayIconPreset({
|
|
|
465
471
|
// src/components/PlayerCenterOverlay.tsx
|
|
466
472
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
467
473
|
var ENABLE_AUDIO_PROMPT = "Tap to enable audio";
|
|
474
|
+
var ENABLE_VIDEO_PROMPT = "Tap to enable video";
|
|
468
475
|
function PlayerCenterOverlay({
|
|
469
476
|
kind,
|
|
470
477
|
playIconPreset,
|
|
471
478
|
onPlay,
|
|
472
|
-
onEnableAudio
|
|
479
|
+
onEnableAudio,
|
|
480
|
+
onReturnToVideo
|
|
473
481
|
}) {
|
|
474
482
|
if (kind === "none") return null;
|
|
475
483
|
const isPlay = kind === "play";
|
|
484
|
+
const isReturnVideo = kind === "return-video";
|
|
485
|
+
const label = isPlay ? "Play" : isReturnVideo ? ENABLE_VIDEO_PROMPT : ENABLE_AUDIO_PROMPT;
|
|
486
|
+
const activate = () => {
|
|
487
|
+
if (isPlay) onPlay();
|
|
488
|
+
else if (isReturnVideo) onReturnToVideo?.();
|
|
489
|
+
else onEnableAudio();
|
|
490
|
+
};
|
|
476
491
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
477
492
|
"div",
|
|
478
493
|
{
|
|
479
494
|
className: "nsg-player-center-overlay",
|
|
480
495
|
onClick: (event) => {
|
|
481
496
|
event.stopPropagation();
|
|
482
|
-
|
|
483
|
-
else onEnableAudio();
|
|
497
|
+
activate();
|
|
484
498
|
},
|
|
485
499
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
486
500
|
"button",
|
|
487
501
|
{
|
|
488
502
|
type: "button",
|
|
489
503
|
className: "nsg-player-center-btn",
|
|
490
|
-
"aria-label":
|
|
504
|
+
"aria-label": label,
|
|
491
505
|
onClick: (event) => {
|
|
492
506
|
event.stopPropagation();
|
|
493
|
-
|
|
494
|
-
else onEnableAudio();
|
|
507
|
+
activate();
|
|
495
508
|
},
|
|
496
509
|
children: [
|
|
497
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "nsg-player-center-disc", children: isPlay ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PlayIconPreset, { preset: playIconPreset, size: 36 }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "34", height: "34", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M3 10v4h3.2L11 19V5L6.2 10H3zm11.5 2A4.5 4.5 0 0 0 12 8.2v7.6A4.5 4.5 0 0 0 14.5 12zm3.5 0a8 8 0 0 0-3.2-6.4v2.3a5.7 5.7 0 0 1 0 8.2v2.3A8 8 0 0 0 18 12z" }) }) }),
|
|
498
|
-
isPlay ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "nsg-player-center-label", children:
|
|
510
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "nsg-player-center-disc", children: isPlay ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PlayIconPreset, { preset: playIconPreset, size: 36 }) : isReturnVideo ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AudioModeGlyph, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "34", height: "34", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M3 10v4h3.2L11 19V5L6.2 10H3zm11.5 2A4.5 4.5 0 0 0 12 8.2v7.6A4.5 4.5 0 0 0 14.5 12zm3.5 0a8 8 0 0 0-3.2-6.4v2.3a5.7 5.7 0 0 1 0 8.2v2.3A8 8 0 0 0 18 12z" }) }) }),
|
|
511
|
+
isPlay ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "nsg-player-center-label", children: label })
|
|
499
512
|
]
|
|
500
513
|
}
|
|
501
514
|
)
|
|
502
515
|
}
|
|
503
516
|
);
|
|
504
517
|
}
|
|
518
|
+
function AudioModeGlyph() {
|
|
519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "34", height: "34", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 3a9 9 0 0 0-9 9v7a2 2 0 0 0 2 2h2v-8H5v-1a7 7 0 0 1 14 0v1h-2v8h2a2 2 0 0 0 2-2v-7a9 9 0 0 0-9-9z" }) });
|
|
520
|
+
}
|
|
505
521
|
|
|
506
522
|
// src/components/PlayerMenu.tsx
|
|
507
523
|
var import_react2 = require("react");
|
|
@@ -722,49 +738,9 @@ function PlaybackSpeedSelector({
|
|
|
722
738
|
)) });
|
|
723
739
|
}
|
|
724
740
|
|
|
725
|
-
// src/components/QualitySelector.tsx
|
|
726
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
727
|
-
function QualitySelector({
|
|
728
|
-
qualities,
|
|
729
|
-
selection,
|
|
730
|
-
activeLevel,
|
|
731
|
-
onSelect
|
|
732
|
-
}) {
|
|
733
|
-
if (qualities.length <= 1) return null;
|
|
734
|
-
const sorted = [...qualities].sort(
|
|
735
|
-
(a, b) => b.height - a.height || b.bitrate - a.bitrate
|
|
736
|
-
);
|
|
737
|
-
const activeLabel = activeLevel >= 0 ? qualities.find((q) => q.index === activeLevel)?.label : void 0;
|
|
738
|
-
const buttonLabel = selection === "auto" ? activeLabel ? `Auto (${activeLabel})` : "Auto" : qualities.find((q) => q.index === selection)?.label ?? "Quality";
|
|
739
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(PlayerMenu, { label: "Quality", buttonLabel, menuKind: "quality", children: [
|
|
740
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
741
|
-
PlayerMenuItem,
|
|
742
|
-
{
|
|
743
|
-
active: selection === "auto",
|
|
744
|
-
menuKind: "quality",
|
|
745
|
-
onSelect: () => onSelect("auto"),
|
|
746
|
-
children: [
|
|
747
|
-
"Auto",
|
|
748
|
-
activeLabel ? ` (${activeLabel})` : ""
|
|
749
|
-
]
|
|
750
|
-
}
|
|
751
|
-
),
|
|
752
|
-
sorted.map((level) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
753
|
-
PlayerMenuItem,
|
|
754
|
-
{
|
|
755
|
-
active: selection === level.index,
|
|
756
|
-
menuKind: "quality",
|
|
757
|
-
onSelect: () => onSelect(level.index),
|
|
758
|
-
children: level.label
|
|
759
|
-
},
|
|
760
|
-
level.index
|
|
761
|
-
))
|
|
762
|
-
] });
|
|
763
|
-
}
|
|
764
|
-
|
|
765
741
|
// src/components/SeekBar.tsx
|
|
766
742
|
var import_react5 = require("react");
|
|
767
|
-
var
|
|
743
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
768
744
|
var INITIAL_HOVER = {
|
|
769
745
|
visible: false,
|
|
770
746
|
time: 0,
|
|
@@ -824,7 +800,7 @@ function SeekBar({
|
|
|
824
800
|
onSeek(max);
|
|
825
801
|
}
|
|
826
802
|
};
|
|
827
|
-
return /* @__PURE__ */ (0,
|
|
803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
828
804
|
"div",
|
|
829
805
|
{
|
|
830
806
|
ref: trackRef,
|
|
@@ -835,28 +811,28 @@ function SeekBar({
|
|
|
835
811
|
onPointerDown,
|
|
836
812
|
role: "presentation",
|
|
837
813
|
children: [
|
|
838
|
-
/* @__PURE__ */ (0,
|
|
814
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
839
815
|
"div",
|
|
840
816
|
{
|
|
841
817
|
className: "nsg-player-seek__buffered",
|
|
842
818
|
style: { width: `${bufferedPct}%` }
|
|
843
819
|
}
|
|
844
820
|
),
|
|
845
|
-
/* @__PURE__ */ (0,
|
|
821
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
846
822
|
"div",
|
|
847
823
|
{
|
|
848
824
|
className: "nsg-player-seek__played",
|
|
849
825
|
style: { width: `${playedPct}%` }
|
|
850
826
|
}
|
|
851
827
|
),
|
|
852
|
-
hover.visible && max > 0 ? /* @__PURE__ */ (0,
|
|
828
|
+
hover.visible && max > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
853
829
|
"div",
|
|
854
830
|
{
|
|
855
831
|
className: "nsg-player-seek__tooltip",
|
|
856
832
|
style: { left: `${hover.percent}%` },
|
|
857
833
|
role: "tooltip",
|
|
858
834
|
children: [
|
|
859
|
-
previewUrl ? /* @__PURE__ */ (0,
|
|
835
|
+
previewUrl ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
860
836
|
"img",
|
|
861
837
|
{
|
|
862
838
|
className: "nsg-player-seek__preview",
|
|
@@ -869,7 +845,7 @@ function SeekBar({
|
|
|
869
845
|
]
|
|
870
846
|
}
|
|
871
847
|
) : null,
|
|
872
|
-
/* @__PURE__ */ (0,
|
|
848
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
873
849
|
"input",
|
|
874
850
|
{
|
|
875
851
|
ref: seekInputRef,
|
|
@@ -890,38 +866,273 @@ function SeekBar({
|
|
|
890
866
|
);
|
|
891
867
|
}
|
|
892
868
|
|
|
893
|
-
// src/components/
|
|
894
|
-
var
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
869
|
+
// src/components/SettingsMenu.tsx
|
|
870
|
+
var import_react6 = require("react");
|
|
871
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
872
|
+
function SettingsMenu({
|
|
873
|
+
showQuality,
|
|
874
|
+
qualities,
|
|
875
|
+
qualitySelection,
|
|
876
|
+
activeLevel,
|
|
877
|
+
onQualityChange,
|
|
878
|
+
showZoom,
|
|
879
|
+
zoom,
|
|
880
|
+
onZoomChange,
|
|
881
|
+
captions,
|
|
882
|
+
selectedCaption,
|
|
883
|
+
onCaptionChange,
|
|
884
|
+
textTracks,
|
|
885
|
+
selectedTextTrack,
|
|
886
|
+
onTextTrackChange,
|
|
887
|
+
captionStatus
|
|
899
888
|
}) {
|
|
900
|
-
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
889
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
890
|
+
const [panel, setPanel] = (0, import_react6.useState)("root");
|
|
891
|
+
const rootRef = (0, import_react6.useRef)(null);
|
|
892
|
+
const menuId = (0, import_react6.useId)();
|
|
893
|
+
const qualityLevels = showQuality && qualities.length > 1 ? [...qualities].sort((a, b) => b.height - a.height || b.bitrate - a.bitrate) : [];
|
|
894
|
+
const showQualityRow = qualityLevels.length > 0;
|
|
895
|
+
const showSubtitleRow = captions.length > 0 || textTracks.length > 0;
|
|
896
|
+
const showZoomRow = showZoom;
|
|
897
|
+
const hasRows = showQualityRow || showZoomRow || showSubtitleRow;
|
|
898
|
+
const activeQuality = activeLevel >= 0 ? qualities.find((level) => level.index === activeLevel)?.label : void 0;
|
|
899
|
+
const qualityValue = qualitySelection === "auto" ? activeQuality ? `Auto (${activeQuality})` : "Auto" : qualities.find((level) => level.index === qualitySelection)?.label ?? "Auto";
|
|
900
|
+
const captionValue = selectedCaption ? captions.find((track) => track.language === selectedCaption)?.label ?? "On" : selectedTextTrack === "off" ? "Off" : textTracks.find((track) => track.index === selectedTextTrack)?.label ?? "On";
|
|
901
|
+
(0, import_react6.useEffect)(() => {
|
|
902
|
+
if (!open) return;
|
|
903
|
+
const onPointerDown = (event) => {
|
|
904
|
+
if (!rootRef.current?.contains(event.target)) {
|
|
905
|
+
setOpen(false);
|
|
906
|
+
setPanel("root");
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
const onKeyDown = (event) => {
|
|
910
|
+
if (event.key === "Escape") {
|
|
911
|
+
setOpen(false);
|
|
912
|
+
setPanel("root");
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
document.addEventListener("mousedown", onPointerDown);
|
|
916
|
+
document.addEventListener("keydown", onKeyDown);
|
|
917
|
+
return () => {
|
|
918
|
+
document.removeEventListener("mousedown", onPointerDown);
|
|
919
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
920
|
+
};
|
|
921
|
+
}, [open]);
|
|
922
|
+
if (!hasRows) return null;
|
|
923
|
+
const title = panel === "quality" ? "Quality" : panel === "zoom" ? "Zoom" : panel === "subtitles" ? "Subtitles" : "Settings";
|
|
924
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { ref: rootRef, className: "nsg-player-menu", children: [
|
|
925
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
926
|
+
"button",
|
|
905
927
|
{
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
928
|
+
type: "button",
|
|
929
|
+
className: "nsg-player-btn",
|
|
930
|
+
"aria-label": "Settings",
|
|
931
|
+
"aria-haspopup": "menu",
|
|
932
|
+
"aria-expanded": open,
|
|
933
|
+
"aria-controls": menuId,
|
|
934
|
+
onClick: (event) => {
|
|
935
|
+
event.stopPropagation();
|
|
936
|
+
setOpen((current) => {
|
|
937
|
+
if (current) setPanel("root");
|
|
938
|
+
return !current;
|
|
939
|
+
});
|
|
940
|
+
},
|
|
941
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SettingsIcon, {})
|
|
909
942
|
}
|
|
910
943
|
),
|
|
911
|
-
|
|
912
|
-
|
|
944
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
945
|
+
"div",
|
|
913
946
|
{
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
947
|
+
id: menuId,
|
|
948
|
+
role: "menu",
|
|
949
|
+
"aria-label": title,
|
|
950
|
+
className: "nsg-player-menu__panel nsg-player-settings",
|
|
951
|
+
onClick: (event) => event.stopPropagation(),
|
|
952
|
+
children: panel === "root" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
953
|
+
showQualityRow ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
954
|
+
"button",
|
|
955
|
+
{
|
|
956
|
+
type: "button",
|
|
957
|
+
role: "menuitem",
|
|
958
|
+
className: "nsg-player-menu__item nsg-player-settings__row",
|
|
959
|
+
onClick: () => setPanel("quality"),
|
|
960
|
+
children: [
|
|
961
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "nsg-player-settings__name", children: [
|
|
962
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(QualityIcon, {}),
|
|
963
|
+
"Quality"
|
|
964
|
+
] }),
|
|
965
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "nsg-player-settings__value", children: qualityValue })
|
|
966
|
+
]
|
|
967
|
+
}
|
|
968
|
+
) : null,
|
|
969
|
+
showZoomRow ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
970
|
+
"button",
|
|
971
|
+
{
|
|
972
|
+
type: "button",
|
|
973
|
+
role: "menuitem",
|
|
974
|
+
className: "nsg-player-menu__item nsg-player-settings__row",
|
|
975
|
+
onClick: () => setPanel("zoom"),
|
|
976
|
+
children: [
|
|
977
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "nsg-player-settings__name", children: [
|
|
978
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ZoomIcon, {}),
|
|
979
|
+
"Zoom"
|
|
980
|
+
] }),
|
|
981
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "nsg-player-settings__value", children: [
|
|
982
|
+
zoom,
|
|
983
|
+
"\xD7"
|
|
984
|
+
] })
|
|
985
|
+
]
|
|
986
|
+
}
|
|
987
|
+
) : null,
|
|
988
|
+
showSubtitleRow ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
989
|
+
"button",
|
|
990
|
+
{
|
|
991
|
+
type: "button",
|
|
992
|
+
role: "menuitem",
|
|
993
|
+
className: "nsg-player-menu__item nsg-player-settings__row",
|
|
994
|
+
onClick: () => setPanel("subtitles"),
|
|
995
|
+
children: [
|
|
996
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "nsg-player-settings__name", children: [
|
|
997
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SubtitlesIcon, {}),
|
|
998
|
+
"Subtitles"
|
|
999
|
+
] }),
|
|
1000
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "nsg-player-settings__value", children: captionValue })
|
|
1001
|
+
]
|
|
1002
|
+
}
|
|
1003
|
+
) : null
|
|
1004
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1005
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "nsg-player-settings__header", children: [
|
|
1006
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1007
|
+
"button",
|
|
1008
|
+
{
|
|
1009
|
+
type: "button",
|
|
1010
|
+
className: "nsg-player-settings__back",
|
|
1011
|
+
"aria-label": "Back",
|
|
1012
|
+
onClick: () => setPanel("root"),
|
|
1013
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BackIcon, {})
|
|
1014
|
+
}
|
|
1015
|
+
),
|
|
1016
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: title })
|
|
1017
|
+
] }),
|
|
1018
|
+
panel === "quality" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1019
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1020
|
+
Option,
|
|
1021
|
+
{
|
|
1022
|
+
active: qualitySelection === "auto",
|
|
1023
|
+
onSelect: () => onQualityChange("auto"),
|
|
1024
|
+
children: [
|
|
1025
|
+
"Auto",
|
|
1026
|
+
activeQuality ? ` (${activeQuality})` : ""
|
|
1027
|
+
]
|
|
1028
|
+
}
|
|
1029
|
+
),
|
|
1030
|
+
qualityLevels.map((level) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1031
|
+
Option,
|
|
1032
|
+
{
|
|
1033
|
+
active: qualitySelection === level.index,
|
|
1034
|
+
onSelect: () => onQualityChange(level.index),
|
|
1035
|
+
children: level.label
|
|
1036
|
+
},
|
|
1037
|
+
level.index
|
|
1038
|
+
))
|
|
1039
|
+
] }) : null,
|
|
1040
|
+
panel === "zoom" ? ZOOM_STEPS.map((level) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1041
|
+
Option,
|
|
1042
|
+
{
|
|
1043
|
+
active: zoom === level,
|
|
1044
|
+
onSelect: () => onZoomChange(level),
|
|
1045
|
+
children: [
|
|
1046
|
+
level,
|
|
1047
|
+
"\xD7"
|
|
1048
|
+
]
|
|
1049
|
+
},
|
|
1050
|
+
level
|
|
1051
|
+
)) : null,
|
|
1052
|
+
panel === "subtitles" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1053
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1054
|
+
Option,
|
|
1055
|
+
{
|
|
1056
|
+
active: !selectedCaption && selectedTextTrack === "off",
|
|
1057
|
+
onSelect: () => {
|
|
1058
|
+
onCaptionChange?.(null);
|
|
1059
|
+
onTextTrackChange("off");
|
|
1060
|
+
},
|
|
1061
|
+
children: "Off"
|
|
1062
|
+
}
|
|
1063
|
+
),
|
|
1064
|
+
captions.map((track) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1065
|
+
Option,
|
|
1066
|
+
{
|
|
1067
|
+
active: selectedCaption === track.language,
|
|
1068
|
+
onSelect: () => {
|
|
1069
|
+
onTextTrackChange("off");
|
|
1070
|
+
onCaptionChange?.(track.language);
|
|
1071
|
+
},
|
|
1072
|
+
children: [
|
|
1073
|
+
track.label,
|
|
1074
|
+
track.generated ? " (auto)" : ""
|
|
1075
|
+
]
|
|
1076
|
+
},
|
|
1077
|
+
track.language
|
|
1078
|
+
)),
|
|
1079
|
+
captions.length === 0 ? textTracks.map((track) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1080
|
+
Option,
|
|
1081
|
+
{
|
|
1082
|
+
active: selectedTextTrack === track.index,
|
|
1083
|
+
onSelect: () => onTextTrackChange(track.index),
|
|
1084
|
+
children: track.label
|
|
1085
|
+
},
|
|
1086
|
+
track.id
|
|
1087
|
+
)) : null,
|
|
1088
|
+
captionStatus ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "nsg-player-settings__status", children: captionStatus }) : null
|
|
1089
|
+
] }) : null
|
|
1090
|
+
] })
|
|
1091
|
+
}
|
|
1092
|
+
) : null
|
|
920
1093
|
] });
|
|
921
1094
|
}
|
|
1095
|
+
function Option({
|
|
1096
|
+
active,
|
|
1097
|
+
children,
|
|
1098
|
+
onSelect
|
|
1099
|
+
}) {
|
|
1100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1101
|
+
"button",
|
|
1102
|
+
{
|
|
1103
|
+
type: "button",
|
|
1104
|
+
role: "menuitemradio",
|
|
1105
|
+
"aria-checked": active,
|
|
1106
|
+
className: "nsg-player-menu__item nsg-player-settings__row",
|
|
1107
|
+
onClick: (event) => {
|
|
1108
|
+
event.stopPropagation();
|
|
1109
|
+
onSelect();
|
|
1110
|
+
},
|
|
1111
|
+
children: [
|
|
1112
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "nsg-player-settings__check", "aria-hidden": true, children: active ? "\u2713" : "" }),
|
|
1113
|
+
children
|
|
1114
|
+
]
|
|
1115
|
+
}
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
function QualityIcon() {
|
|
1119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M4 6h16v10H4V6zm2 2v6h12V8H6zm3 10h6v2H9v-2z" }) });
|
|
1120
|
+
}
|
|
1121
|
+
function ZoomIcon() {
|
|
1122
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M15.5 14h-.8l-.3-.3a6 6 0 1 0-.7.7l.3.3v.8l4.5 4.5 1.5-1.5-4.5-4.5zM10 14.5A4.5 4.5 0 1 1 10 5.5a4.5 4.5 0 0 1 0 9z" }) });
|
|
1123
|
+
}
|
|
1124
|
+
function SubtitlesIcon() {
|
|
1125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M4 5h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zm1.5 5.5h5v1.5h-5v-1.5zm7 0h6v1.5h-6v-1.5zm-7 3.5h3.5V15.5H5.5V14zm5 0H18.5v1.5h-8V14z" }) });
|
|
1126
|
+
}
|
|
1127
|
+
function SettingsIcon() {
|
|
1128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M19.4 13a7.8 7.8 0 0 0 .1-1 7.8 7.8 0 0 0-.1-1l2.1-1.6a.5.5 0 0 0 .1-.7l-2-3.4a.5.5 0 0 0-.6-.2l-2.5 1a7.3 7.3 0 0 0-1.7-1l-.4-2.6a.5.5 0 0 0-.5-.4h-4a.5.5 0 0 0-.5.4l-.4 2.6a7.3 7.3 0 0 0-1.7 1l-2.5-1a.5.5 0 0 0-.6.2l-2 3.4a.5.5 0 0 0 .1.7L4.6 11a7.8 7.8 0 0 0-.1 1 7.8 7.8 0 0 0 .1 1l-2.1 1.6a.5.5 0 0 0-.1.7l2 3.4a.5.5 0 0 0 .6.2l2.5-1a7.3 7.3 0 0 0 1.7 1l.4 2.6a.5.5 0 0 0 .5.4h4a.5.5 0 0 0 .5-.4l.4-2.6a7.3 7.3 0 0 0 1.7-1l2.5 1a.5.5 0 0 0 .6-.2l2-3.4a.5.5 0 0 0-.1-.7L19.4 13zM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5z" }) });
|
|
1129
|
+
}
|
|
1130
|
+
function BackIcon() {
|
|
1131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M15.4 7.4 14 6l-6 6 6 6 1.4-1.4L10.8 12z" }) });
|
|
1132
|
+
}
|
|
922
1133
|
|
|
923
1134
|
// src/components/PlayerControlBar.tsx
|
|
924
|
-
var
|
|
1135
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
925
1136
|
function PlayerControlBar(props) {
|
|
926
1137
|
const {
|
|
927
1138
|
config,
|
|
@@ -954,22 +1165,36 @@ function PlayerControlBar(props) {
|
|
|
954
1165
|
onTextTrackChange,
|
|
955
1166
|
onAudioTrackChange,
|
|
956
1167
|
onToggleFullscreen,
|
|
957
|
-
|
|
958
|
-
onZoomOut,
|
|
1168
|
+
onZoomChange,
|
|
959
1169
|
seekBarRef,
|
|
960
|
-
getSeekPreview
|
|
1170
|
+
getSeekPreview,
|
|
1171
|
+
mediaMode = "video",
|
|
1172
|
+
audioAvailable = false,
|
|
1173
|
+
onMediaModeChange,
|
|
1174
|
+
sidecarCaptions = [],
|
|
1175
|
+
selectedSidecar = null,
|
|
1176
|
+
onSidecarChange,
|
|
1177
|
+
captionStatus = null,
|
|
1178
|
+
onPointerEnter,
|
|
1179
|
+
onPointerLeave,
|
|
1180
|
+
onFocusCapture,
|
|
1181
|
+
onBlurCapture
|
|
961
1182
|
} = props;
|
|
962
1183
|
const controls = config.controls;
|
|
963
1184
|
const showZoom = config.player.zoomEnabled && controls.showZoom;
|
|
964
1185
|
const skipSeconds = config.player.skipSeconds;
|
|
965
|
-
return /* @__PURE__ */ (0,
|
|
1186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
966
1187
|
"div",
|
|
967
1188
|
{
|
|
968
1189
|
className: "nsg-player-control-bar",
|
|
969
1190
|
onClick: (event) => event.stopPropagation(),
|
|
970
1191
|
onKeyDown: (event) => event.stopPropagation(),
|
|
1192
|
+
onPointerEnter,
|
|
1193
|
+
onPointerLeave,
|
|
1194
|
+
onFocusCapture,
|
|
1195
|
+
onBlurCapture,
|
|
971
1196
|
children: [
|
|
972
|
-
/* @__PURE__ */ (0,
|
|
1197
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
973
1198
|
SeekBar,
|
|
974
1199
|
{
|
|
975
1200
|
currentTime,
|
|
@@ -980,19 +1205,19 @@ function PlayerControlBar(props) {
|
|
|
980
1205
|
getSeekPreview
|
|
981
1206
|
}
|
|
982
1207
|
),
|
|
983
|
-
/* @__PURE__ */ (0,
|
|
984
|
-
/* @__PURE__ */ (0,
|
|
1208
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "nsg-player-control-row", children: [
|
|
1209
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
985
1210
|
"button",
|
|
986
1211
|
{
|
|
987
1212
|
type: "button",
|
|
988
1213
|
className: "nsg-player-btn",
|
|
989
1214
|
"aria-label": isPlaying ? "Pause" : "Play",
|
|
990
1215
|
onClick: onTogglePlay,
|
|
991
|
-
children: isPlaying ? /* @__PURE__ */ (0,
|
|
1216
|
+
children: isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PauseIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PlayIcon, {})
|
|
992
1217
|
}
|
|
993
1218
|
),
|
|
994
|
-
controls.showSkip ? /* @__PURE__ */ (0,
|
|
995
|
-
/* @__PURE__ */ (0,
|
|
1219
|
+
controls.showSkip ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1220
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
996
1221
|
"button",
|
|
997
1222
|
{
|
|
998
1223
|
type: "button",
|
|
@@ -1000,10 +1225,10 @@ function PlayerControlBar(props) {
|
|
|
1000
1225
|
style: { color: "var(--player-skip-icon)" },
|
|
1001
1226
|
"aria-label": `Back ${skipSeconds} seconds`,
|
|
1002
1227
|
onClick: () => onSkip("backward"),
|
|
1003
|
-
children: /* @__PURE__ */ (0,
|
|
1228
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SkipIcon, { label: String(skipSeconds), forward: false })
|
|
1004
1229
|
}
|
|
1005
1230
|
),
|
|
1006
|
-
/* @__PURE__ */ (0,
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1007
1232
|
"button",
|
|
1008
1233
|
{
|
|
1009
1234
|
type: "button",
|
|
@@ -1011,12 +1236,12 @@ function PlayerControlBar(props) {
|
|
|
1011
1236
|
style: { color: "var(--player-skip-icon)" },
|
|
1012
1237
|
"aria-label": `Forward ${skipSeconds} seconds`,
|
|
1013
1238
|
onClick: () => onSkip("forward"),
|
|
1014
|
-
children: /* @__PURE__ */ (0,
|
|
1239
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SkipIcon, { label: String(skipSeconds), forward: true })
|
|
1015
1240
|
}
|
|
1016
1241
|
)
|
|
1017
1242
|
] }) : null,
|
|
1018
|
-
controls.showVolume ? /* @__PURE__ */ (0,
|
|
1019
|
-
/* @__PURE__ */ (0,
|
|
1243
|
+
controls.showVolume ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "nsg-player-volume", children: [
|
|
1244
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1020
1245
|
"button",
|
|
1021
1246
|
{
|
|
1022
1247
|
type: "button",
|
|
@@ -1024,10 +1249,10 @@ function PlayerControlBar(props) {
|
|
|
1024
1249
|
style: { color: "var(--player-volume-icon)" },
|
|
1025
1250
|
"aria-label": muted || volume === 0 ? "Unmute" : "Mute",
|
|
1026
1251
|
onClick: onToggleMute,
|
|
1027
|
-
children: muted || volume === 0 ? /* @__PURE__ */ (0,
|
|
1252
|
+
children: muted || volume === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MuteIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(VolumeIcon, {})
|
|
1028
1253
|
}
|
|
1029
1254
|
),
|
|
1030
|
-
/* @__PURE__ */ (0,
|
|
1255
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1031
1256
|
"input",
|
|
1032
1257
|
{
|
|
1033
1258
|
type: "range",
|
|
@@ -1041,53 +1266,25 @@ function PlayerControlBar(props) {
|
|
|
1041
1266
|
}
|
|
1042
1267
|
)
|
|
1043
1268
|
] }) : null,
|
|
1044
|
-
/* @__PURE__ */ (0,
|
|
1269
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "nsg-player-time", children: [
|
|
1045
1270
|
formatPlaybackTime(currentTime),
|
|
1046
1271
|
" / ",
|
|
1047
1272
|
formatPlaybackTime(duration)
|
|
1048
1273
|
] }),
|
|
1049
|
-
controls.showLive && isLive ? /* @__PURE__ */ (0,
|
|
1050
|
-
/* @__PURE__ */ (0,
|
|
1051
|
-
|
|
1052
|
-
"
|
|
1274
|
+
controls.showLive && isLive ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LiveBadgeButton, { atLiveEdge, onGoToLive }) : null,
|
|
1275
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "nsg-player-control-row-end", children: [
|
|
1276
|
+
onMediaModeChange && audioAvailable ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1277
|
+
"button",
|
|
1053
1278
|
{
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
"aria-label":
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { style: { fontVariantNumeric: "tabular-nums" }, children: [
|
|
1061
|
-
zoom,
|
|
1062
|
-
"\xD7"
|
|
1063
|
-
] })
|
|
1064
|
-
] }),
|
|
1065
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1066
|
-
"button",
|
|
1067
|
-
{
|
|
1068
|
-
type: "button",
|
|
1069
|
-
className: "nsg-player-btn",
|
|
1070
|
-
"aria-label": `Zoom out (current ${zoom}\xD7)`,
|
|
1071
|
-
disabled: zoom <= 1,
|
|
1072
|
-
onClick: onZoomOut,
|
|
1073
|
-
children: "\u2212"
|
|
1074
|
-
}
|
|
1075
|
-
),
|
|
1076
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1077
|
-
"button",
|
|
1078
|
-
{
|
|
1079
|
-
type: "button",
|
|
1080
|
-
className: "nsg-player-btn",
|
|
1081
|
-
"aria-label": `Zoom in (current ${zoom}\xD7)`,
|
|
1082
|
-
disabled: zoom >= 2,
|
|
1083
|
-
onClick: onZoomIn,
|
|
1084
|
-
children: "+"
|
|
1085
|
-
}
|
|
1086
|
-
)
|
|
1087
|
-
]
|
|
1279
|
+
type: "button",
|
|
1280
|
+
className: "nsg-player-btn",
|
|
1281
|
+
"aria-label": mediaMode === "audio" ? "Switch to video" : "Listen to audio",
|
|
1282
|
+
"aria-pressed": mediaMode === "audio",
|
|
1283
|
+
onClick: () => onMediaModeChange(mediaMode === "audio" ? "video" : "audio"),
|
|
1284
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AudioModeIcon, { active: mediaMode === "audio" })
|
|
1088
1285
|
}
|
|
1089
1286
|
) : null,
|
|
1090
|
-
controls.showSpeed && !isLive ? /* @__PURE__ */ (0,
|
|
1287
|
+
controls.showSpeed && !isLive ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1091
1288
|
PlaybackSpeedSelector,
|
|
1092
1289
|
{
|
|
1093
1290
|
rate: playbackRate,
|
|
@@ -1095,24 +1292,27 @@ function PlayerControlBar(props) {
|
|
|
1095
1292
|
onSelect: onPlaybackRateChange
|
|
1096
1293
|
}
|
|
1097
1294
|
) : null,
|
|
1098
|
-
|
|
1099
|
-
|
|
1295
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1296
|
+
SettingsMenu,
|
|
1100
1297
|
{
|
|
1298
|
+
showQuality: controls.showQuality && mediaMode !== "audio",
|
|
1101
1299
|
qualities,
|
|
1102
|
-
|
|
1300
|
+
qualitySelection,
|
|
1103
1301
|
activeLevel,
|
|
1104
|
-
|
|
1302
|
+
onQualityChange,
|
|
1303
|
+
showZoom,
|
|
1304
|
+
zoom,
|
|
1305
|
+
onZoomChange,
|
|
1306
|
+
captions: mediaMode === "audio" ? [] : sidecarCaptions,
|
|
1307
|
+
selectedCaption: selectedSidecar,
|
|
1308
|
+
onCaptionChange: onSidecarChange,
|
|
1309
|
+
textTracks: controls.showCaptions && mediaMode !== "audio" ? textTracks : [],
|
|
1310
|
+
selectedTextTrack,
|
|
1311
|
+
onTextTrackChange,
|
|
1312
|
+
captionStatus
|
|
1105
1313
|
}
|
|
1106
|
-
)
|
|
1107
|
-
controls.
|
|
1108
|
-
TextTrackSelector,
|
|
1109
|
-
{
|
|
1110
|
-
tracks: textTracks,
|
|
1111
|
-
selection: selectedTextTrack,
|
|
1112
|
-
onSelect: onTextTrackChange
|
|
1113
|
-
}
|
|
1114
|
-
) : null,
|
|
1115
|
-
controls.showAudio ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1314
|
+
),
|
|
1315
|
+
controls.showAudio && mediaMode !== "audio" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1116
1316
|
AudioTrackSelector,
|
|
1117
1317
|
{
|
|
1118
1318
|
tracks: audioTracks,
|
|
@@ -1120,7 +1320,7 @@ function PlayerControlBar(props) {
|
|
|
1120
1320
|
onSelect: onAudioTrackChange
|
|
1121
1321
|
}
|
|
1122
1322
|
) : null,
|
|
1123
|
-
controls.showFullscreen ? /* @__PURE__ */ (0,
|
|
1323
|
+
controls.showFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1124
1324
|
"button",
|
|
1125
1325
|
{
|
|
1126
1326
|
type: "button",
|
|
@@ -1136,27 +1336,40 @@ function PlayerControlBar(props) {
|
|
|
1136
1336
|
}
|
|
1137
1337
|
);
|
|
1138
1338
|
}
|
|
1339
|
+
function AudioModeIcon({ active }) {
|
|
1340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1341
|
+
"svg",
|
|
1342
|
+
{
|
|
1343
|
+
width: "18",
|
|
1344
|
+
height: "18",
|
|
1345
|
+
viewBox: "0 0 24 24",
|
|
1346
|
+
fill: active ? "var(--player-quality-active-text, currentColor)" : "currentColor",
|
|
1347
|
+
"aria-hidden": true,
|
|
1348
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M12 3a9 9 0 0 0-9 9v7a2 2 0 0 0 2 2h2v-8H5v-1a7 7 0 0 1 14 0v1h-2v8h2a2 2 0 0 0 2-2v-7a9 9 0 0 0-9-9z" })
|
|
1349
|
+
}
|
|
1350
|
+
);
|
|
1351
|
+
}
|
|
1139
1352
|
function PlayIcon() {
|
|
1140
|
-
return /* @__PURE__ */ (0,
|
|
1353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M8 5v14l11-7z" }) });
|
|
1141
1354
|
}
|
|
1142
1355
|
function PauseIcon() {
|
|
1143
|
-
return /* @__PURE__ */ (0,
|
|
1356
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M6 5h4v14H6zm8 0h4v14h-4z" }) });
|
|
1144
1357
|
}
|
|
1145
1358
|
function SkipIcon({ label, forward }) {
|
|
1146
|
-
return /* @__PURE__ */ (0,
|
|
1147
|
-
/* @__PURE__ */ (0,
|
|
1148
|
-
/* @__PURE__ */ (0,
|
|
1359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { style: { display: "flex", flexDirection: "column", alignItems: "center", lineHeight: 1 }, children: [
|
|
1360
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: "16", height: "14", viewBox: "0 0 24 16", fill: "currentColor", "aria-hidden": true, children: forward ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M3 2v12l9-6-9-6zm9 0v12l9-6-9-6z" }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M12 2v12L3 8l9-6zm9 0v12l-9-6 9-6z" }) }),
|
|
1361
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { style: { fontSize: 9, fontWeight: 700 }, children: label })
|
|
1149
1362
|
] });
|
|
1150
1363
|
}
|
|
1151
1364
|
function VolumeIcon() {
|
|
1152
|
-
return /* @__PURE__ */ (0,
|
|
1365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M3 10v4h4l5 5V5L7 10H3zm13.5 2a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4z" }) });
|
|
1153
1366
|
}
|
|
1154
1367
|
function MuteIcon() {
|
|
1155
|
-
return /* @__PURE__ */ (0,
|
|
1368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M16.5 12a4.5 4.5 0 0 0-2.5-4v2.2l2.5 2.5V12zm3.5 0c0 .9-.2 1.7-.5 2.5l1.5 1.5c.6-1.2 1-2.6 1-4 0-3.2-1.8-5.9-4.5-7.2v2.2c1.8 1.1 3 3 3 5.2zM3.3 2 2 3.3 7.7 9H3v6h4l5 5v-6.7l6.7 6.7 1.3-1.3L3.3 2zM14 5l-2.1 2.1L14 9.2V5z" }) });
|
|
1156
1369
|
}
|
|
1157
1370
|
|
|
1158
1371
|
// src/components/PlayerSkipCue.tsx
|
|
1159
|
-
var
|
|
1372
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1160
1373
|
function PlayerSkipCue({
|
|
1161
1374
|
direction,
|
|
1162
1375
|
cueId,
|
|
@@ -1165,14 +1378,14 @@ function PlayerSkipCue({
|
|
|
1165
1378
|
if (!direction) return null;
|
|
1166
1379
|
const isForward = direction === "forward";
|
|
1167
1380
|
const label = isForward ? `+${seconds}` : `-${seconds}`;
|
|
1168
|
-
return /* @__PURE__ */ (0,
|
|
1381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1169
1382
|
"div",
|
|
1170
1383
|
{
|
|
1171
1384
|
className: `nsg-player-skip-cue ${isForward ? "nsg-player-skip-cue--forward" : "nsg-player-skip-cue--backward"}`,
|
|
1172
1385
|
"aria-hidden": true,
|
|
1173
|
-
children: /* @__PURE__ */ (0,
|
|
1174
|
-
/* @__PURE__ */ (0,
|
|
1175
|
-
/* @__PURE__ */ (0,
|
|
1386
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "nsg-player-skip-cue-badge", children: [
|
|
1387
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "nsg-player-skip-cue-disc", children: isForward ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M3 6v12l8.5-6L3 6zm9 0v12l8.5-6L12 6z" }) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M11.5 12 20 6v12l-8.5-6zm-8.5 0L11 6v12L3 12z" }) }) }),
|
|
1388
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: { fontSize: "1.125rem", fontWeight: 600 }, children: label })
|
|
1176
1389
|
] })
|
|
1177
1390
|
},
|
|
1178
1391
|
cueId
|
|
@@ -1180,31 +1393,87 @@ function PlayerSkipCue({
|
|
|
1180
1393
|
}
|
|
1181
1394
|
|
|
1182
1395
|
// src/components/PlayerChrome.tsx
|
|
1183
|
-
var
|
|
1396
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1184
1397
|
function PlayerChrome({
|
|
1185
1398
|
player,
|
|
1186
1399
|
config,
|
|
1187
1400
|
containerRef,
|
|
1188
1401
|
videoSlot,
|
|
1189
1402
|
className,
|
|
1190
|
-
getSeekPreview
|
|
1403
|
+
getSeekPreview,
|
|
1404
|
+
mediaMode,
|
|
1405
|
+
audioAvailable,
|
|
1406
|
+
onMediaModeChange,
|
|
1407
|
+
sidecarCaptions,
|
|
1408
|
+
selectedSidecar,
|
|
1409
|
+
onSidecarChange,
|
|
1410
|
+
captionStatus
|
|
1191
1411
|
}) {
|
|
1192
|
-
const rootRef = (0,
|
|
1193
|
-
const seekBarRef = (0,
|
|
1194
|
-
const skipCueTimerRef = (0,
|
|
1195
|
-
const [skipCue, setSkipCue] = (0,
|
|
1412
|
+
const rootRef = (0, import_react7.useRef)(null);
|
|
1413
|
+
const seekBarRef = (0, import_react7.useRef)(null);
|
|
1414
|
+
const skipCueTimerRef = (0, import_react7.useRef)(null);
|
|
1415
|
+
const [skipCue, setSkipCue] = (0, import_react7.useState)(null);
|
|
1196
1416
|
const controls = usePlayerControls({
|
|
1197
1417
|
player,
|
|
1198
1418
|
config,
|
|
1199
1419
|
containerRef
|
|
1200
1420
|
});
|
|
1421
|
+
const TOOLBAR_IDLE_MS = 5e3;
|
|
1422
|
+
const [toolbarVisible, setToolbarVisible] = (0, import_react7.useState)(true);
|
|
1423
|
+
const toolbarVisibleRef = (0, import_react7.useRef)(true);
|
|
1424
|
+
const controlsPinnedRef = (0, import_react7.useRef)(false);
|
|
1425
|
+
const idleTimerRef = (0, import_react7.useRef)(null);
|
|
1426
|
+
const clearToolbarIdle = (0, import_react7.useCallback)(() => {
|
|
1427
|
+
if (idleTimerRef.current) {
|
|
1428
|
+
window.clearTimeout(idleTimerRef.current);
|
|
1429
|
+
idleTimerRef.current = null;
|
|
1430
|
+
}
|
|
1431
|
+
}, []);
|
|
1432
|
+
const scheduleToolbarHide = (0, import_react7.useCallback)(() => {
|
|
1433
|
+
clearToolbarIdle();
|
|
1434
|
+
idleTimerRef.current = window.setTimeout(() => {
|
|
1435
|
+
if (controlsPinnedRef.current) return;
|
|
1436
|
+
toolbarVisibleRef.current = false;
|
|
1437
|
+
setToolbarVisible(false);
|
|
1438
|
+
}, TOOLBAR_IDLE_MS);
|
|
1439
|
+
}, [clearToolbarIdle]);
|
|
1440
|
+
const revealToolbar = (0, import_react7.useCallback)(() => {
|
|
1441
|
+
if (!toolbarVisibleRef.current) {
|
|
1442
|
+
toolbarVisibleRef.current = true;
|
|
1443
|
+
setToolbarVisible(true);
|
|
1444
|
+
}
|
|
1445
|
+
if (!controlsPinnedRef.current) scheduleToolbarHide();
|
|
1446
|
+
}, [scheduleToolbarHide]);
|
|
1447
|
+
(0, import_react7.useEffect)(() => {
|
|
1448
|
+
if (!controls.showControls) {
|
|
1449
|
+
clearToolbarIdle();
|
|
1450
|
+
toolbarVisibleRef.current = false;
|
|
1451
|
+
setToolbarVisible(false);
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
revealToolbar();
|
|
1455
|
+
return clearToolbarIdle;
|
|
1456
|
+
}, [controls.showControls, revealToolbar, clearToolbarIdle]);
|
|
1457
|
+
const pinToolbar = (0, import_react7.useCallback)(() => {
|
|
1458
|
+
controlsPinnedRef.current = true;
|
|
1459
|
+
clearToolbarIdle();
|
|
1460
|
+
if (!toolbarVisibleRef.current) {
|
|
1461
|
+
toolbarVisibleRef.current = true;
|
|
1462
|
+
setToolbarVisible(true);
|
|
1463
|
+
}
|
|
1464
|
+
}, [clearToolbarIdle]);
|
|
1465
|
+
const releaseToolbar = (0, import_react7.useCallback)(() => {
|
|
1466
|
+
controlsPinnedRef.current = false;
|
|
1467
|
+
scheduleToolbarHide();
|
|
1468
|
+
}, [scheduleToolbarHide]);
|
|
1201
1469
|
const overlay = resolvePlayerOverlay({
|
|
1202
1470
|
showControls: controls.showControls,
|
|
1203
1471
|
isPlaying: controls.isPlaying,
|
|
1204
1472
|
muted: controls.muted,
|
|
1205
|
-
volume: controls.volume
|
|
1473
|
+
volume: controls.volume,
|
|
1474
|
+
mediaMode
|
|
1206
1475
|
});
|
|
1207
|
-
const flashSkipCue = (0,
|
|
1476
|
+
const flashSkipCue = (0, import_react7.useCallback)(
|
|
1208
1477
|
(direction) => {
|
|
1209
1478
|
setSkipCue({ direction, id: Date.now() });
|
|
1210
1479
|
if (skipCueTimerRef.current) window.clearTimeout(skipCueTimerRef.current);
|
|
@@ -1215,7 +1484,7 @@ function PlayerChrome({
|
|
|
1215
1484
|
},
|
|
1216
1485
|
[config.controls.seekCueDurationMs]
|
|
1217
1486
|
);
|
|
1218
|
-
const skip = (0,
|
|
1487
|
+
const skip = (0, import_react7.useCallback)(
|
|
1219
1488
|
(direction) => {
|
|
1220
1489
|
if (!config.controls.showSkip) return;
|
|
1221
1490
|
const delta = direction === "forward" ? config.player.skipSeconds : -config.player.skipSeconds;
|
|
@@ -1229,21 +1498,23 @@ function PlayerChrome({
|
|
|
1229
1498
|
flashSkipCue
|
|
1230
1499
|
]
|
|
1231
1500
|
);
|
|
1232
|
-
(0,
|
|
1501
|
+
(0, import_react7.useEffect)(() => {
|
|
1233
1502
|
return () => {
|
|
1234
1503
|
if (skipCueTimerRef.current) window.clearTimeout(skipCueTimerRef.current);
|
|
1235
1504
|
};
|
|
1236
1505
|
}, []);
|
|
1237
|
-
(0,
|
|
1506
|
+
(0, import_react7.useEffect)(() => {
|
|
1238
1507
|
const root = rootRef.current;
|
|
1239
|
-
if (!root || !controls.showControls
|
|
1508
|
+
if (!root || !controls.showControls) {
|
|
1240
1509
|
return;
|
|
1241
1510
|
}
|
|
1242
1511
|
const onKeyDown = (event) => {
|
|
1512
|
+
revealToolbar();
|
|
1243
1513
|
const target = event.target;
|
|
1244
1514
|
if (target && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable)) {
|
|
1245
1515
|
return;
|
|
1246
1516
|
}
|
|
1517
|
+
if (!config.controls.keyboardShortcuts) return;
|
|
1247
1518
|
switch (event.key) {
|
|
1248
1519
|
case " ":
|
|
1249
1520
|
case "k":
|
|
@@ -1300,17 +1571,20 @@ function PlayerChrome({
|
|
|
1300
1571
|
root.tabIndex = 0;
|
|
1301
1572
|
root.addEventListener("keydown", onKeyDown);
|
|
1302
1573
|
return () => root.removeEventListener("keydown", onKeyDown);
|
|
1303
|
-
}, [controls, config, skip]);
|
|
1304
|
-
return /* @__PURE__ */ (0,
|
|
1574
|
+
}, [controls, config, skip, revealToolbar]);
|
|
1575
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1305
1576
|
"div",
|
|
1306
1577
|
{
|
|
1307
1578
|
ref: rootRef,
|
|
1308
1579
|
className: ["nsg-player-root", className].filter(Boolean).join(" "),
|
|
1309
1580
|
role: "region",
|
|
1310
1581
|
"aria-label": "Video player",
|
|
1582
|
+
onPointerEnter: controls.showControls ? revealToolbar : void 0,
|
|
1583
|
+
onPointerMove: controls.showControls ? revealToolbar : void 0,
|
|
1584
|
+
onPointerDown: controls.showControls ? revealToolbar : void 0,
|
|
1311
1585
|
onClick: controls.showControls ? controls.togglePlay : void 0,
|
|
1312
1586
|
children: [
|
|
1313
|
-
/* @__PURE__ */ (0,
|
|
1587
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1314
1588
|
"div",
|
|
1315
1589
|
{
|
|
1316
1590
|
className: "nsg-player-video-wrap",
|
|
@@ -1318,16 +1592,17 @@ function PlayerChrome({
|
|
|
1318
1592
|
children: videoSlot
|
|
1319
1593
|
}
|
|
1320
1594
|
),
|
|
1321
|
-
/* @__PURE__ */ (0,
|
|
1595
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1322
1596
|
PlayerCenterOverlay,
|
|
1323
1597
|
{
|
|
1324
1598
|
kind: overlay,
|
|
1325
1599
|
playIconPreset: config.theme.playIconPreset,
|
|
1326
1600
|
onPlay: controls.togglePlay,
|
|
1327
|
-
onEnableAudio: controls.enableAudio
|
|
1601
|
+
onEnableAudio: controls.enableAudio,
|
|
1602
|
+
onReturnToVideo: () => onMediaModeChange?.("video")
|
|
1328
1603
|
}
|
|
1329
1604
|
),
|
|
1330
|
-
/* @__PURE__ */ (0,
|
|
1605
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1331
1606
|
PlayerSkipCue,
|
|
1332
1607
|
{
|
|
1333
1608
|
direction: skipCue?.direction ?? null,
|
|
@@ -1336,7 +1611,7 @@ function PlayerChrome({
|
|
|
1336
1611
|
},
|
|
1337
1612
|
skipCue?.id ?? "idle"
|
|
1338
1613
|
),
|
|
1339
|
-
controls.showControls ? /* @__PURE__ */ (0,
|
|
1614
|
+
controls.showControls && toolbarVisible ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1340
1615
|
PlayerControlBar,
|
|
1341
1616
|
{
|
|
1342
1617
|
config,
|
|
@@ -1369,19 +1644,42 @@ function PlayerChrome({
|
|
|
1369
1644
|
onTextTrackChange: controls.setTextTrack,
|
|
1370
1645
|
onAudioTrackChange: controls.setAudioTrack,
|
|
1371
1646
|
onToggleFullscreen: () => void controls.toggleFullscreen(),
|
|
1372
|
-
|
|
1373
|
-
onZoomOut: controls.zoomOut,
|
|
1647
|
+
onZoomChange: controls.setZoom,
|
|
1374
1648
|
seekBarRef,
|
|
1375
|
-
|
|
1649
|
+
mediaMode,
|
|
1650
|
+
audioAvailable,
|
|
1651
|
+
onMediaModeChange,
|
|
1652
|
+
sidecarCaptions,
|
|
1653
|
+
selectedSidecar,
|
|
1654
|
+
onSidecarChange,
|
|
1655
|
+
captionStatus,
|
|
1656
|
+
getSeekPreview,
|
|
1657
|
+
onPointerEnter: pinToolbar,
|
|
1658
|
+
onPointerLeave: releaseToolbar,
|
|
1659
|
+
onFocusCapture: pinToolbar,
|
|
1660
|
+
onBlurCapture: (event) => {
|
|
1661
|
+
const next = event.relatedTarget;
|
|
1662
|
+
if (next instanceof Node && event.currentTarget.contains(next)) return;
|
|
1663
|
+
releaseToolbar();
|
|
1664
|
+
}
|
|
1376
1665
|
}
|
|
1377
|
-
) : null
|
|
1666
|
+
) : null,
|
|
1667
|
+
controls.showControls && !toolbarVisible && Number.isFinite(controls.duration) && controls.duration > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "nsg-player-edge-progress", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1668
|
+
"div",
|
|
1669
|
+
{
|
|
1670
|
+
className: "nsg-player-edge-progress__played",
|
|
1671
|
+
style: {
|
|
1672
|
+
width: `${Math.min(100, controls.currentTime / controls.duration * 100)}%`
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
) }) : null
|
|
1378
1676
|
]
|
|
1379
1677
|
}
|
|
1380
1678
|
);
|
|
1381
1679
|
}
|
|
1382
1680
|
|
|
1383
1681
|
// src/hooks/usePlaybackWatermark.ts
|
|
1384
|
-
var
|
|
1682
|
+
var import_react8 = require("react");
|
|
1385
1683
|
|
|
1386
1684
|
// src/utils/watermarkSchedule.ts
|
|
1387
1685
|
var WATERMARK_TOP_MIN_PCT = 8;
|
|
@@ -1431,11 +1729,11 @@ function usePlaybackWatermark({
|
|
|
1431
1729
|
intervalMaxMs,
|
|
1432
1730
|
reducedMotion = false
|
|
1433
1731
|
}) {
|
|
1434
|
-
const [state, setState] = (0,
|
|
1435
|
-
const showTimerRef = (0,
|
|
1436
|
-
const hideTimerRef = (0,
|
|
1437
|
-
const generationRef = (0,
|
|
1438
|
-
(0,
|
|
1732
|
+
const [state, setState] = (0, import_react8.useState)(HIDDEN);
|
|
1733
|
+
const showTimerRef = (0, import_react8.useRef)(null);
|
|
1734
|
+
const hideTimerRef = (0, import_react8.useRef)(null);
|
|
1735
|
+
const generationRef = (0, import_react8.useRef)(0);
|
|
1736
|
+
(0, import_react8.useEffect)(() => {
|
|
1439
1737
|
const clearTimers = () => {
|
|
1440
1738
|
if (showTimerRef.current !== null) {
|
|
1441
1739
|
window.clearTimeout(showTimerRef.current);
|
|
@@ -1487,12 +1785,15 @@ function usePlaybackWatermark({
|
|
|
1487
1785
|
}
|
|
1488
1786
|
|
|
1489
1787
|
// src/NsgVideoPlayerWithControls.tsx
|
|
1490
|
-
var
|
|
1491
|
-
var NsgVideoPlayerWithControls = (0,
|
|
1492
|
-
const containerRef = (0,
|
|
1493
|
-
const onWatchTimeRef = (0,
|
|
1788
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1789
|
+
var NsgVideoPlayerWithControls = (0, import_react9.forwardRef)(function NsgVideoPlayerWithControls2(props, ref) {
|
|
1790
|
+
const containerRef = (0, import_react9.useRef)(null);
|
|
1791
|
+
const onWatchTimeRef = (0, import_react9.useRef)(props.onWatchTime);
|
|
1494
1792
|
onWatchTimeRef.current = props.onWatchTime;
|
|
1495
|
-
const
|
|
1793
|
+
const pendingSwitchRef = (0, import_react9.useRef)(null);
|
|
1794
|
+
const switchGenerationRef = (0, import_react9.useRef)(0);
|
|
1795
|
+
const videoIdRef = (0, import_react9.useRef)(props.videoId);
|
|
1796
|
+
const resolvedConfig = (0, import_react9.useMemo)(
|
|
1496
1797
|
() => (0, import_video_nsgplayer_core2.mergePlayerConfig)({
|
|
1497
1798
|
...props.config,
|
|
1498
1799
|
controls: {
|
|
@@ -1515,8 +1816,60 @@ var NsgVideoPlayerWithControls = (0, import_react8.forwardRef)(function NsgVideo
|
|
|
1515
1816
|
onPause: props.onPause,
|
|
1516
1817
|
onAuthError: props.onAuthError
|
|
1517
1818
|
});
|
|
1518
|
-
(0,
|
|
1519
|
-
|
|
1819
|
+
(0, import_react9.useImperativeHandle)(ref, () => player, [player]);
|
|
1820
|
+
const requestMediaMode = (mode) => {
|
|
1821
|
+
if (mode === (props.mediaMode ?? "video")) return;
|
|
1822
|
+
const volume = player?.getVolume() ?? 1;
|
|
1823
|
+
const audible = volume > 0 ? volume : 1;
|
|
1824
|
+
const video = videoRef.current;
|
|
1825
|
+
if (video) {
|
|
1826
|
+
video.muted = false;
|
|
1827
|
+
video.volume = audible;
|
|
1828
|
+
}
|
|
1829
|
+
const playbackState = player?.getState();
|
|
1830
|
+
pendingSwitchRef.current = {
|
|
1831
|
+
time: player?.getCurrentTime() ?? 0,
|
|
1832
|
+
rate: player?.getPlaybackRate() ?? 1,
|
|
1833
|
+
volume: audible,
|
|
1834
|
+
playing: playbackState === "playing" || playbackState === "buffering"
|
|
1835
|
+
};
|
|
1836
|
+
props.onMediaModeChange?.(mode);
|
|
1837
|
+
};
|
|
1838
|
+
(0, import_react9.useEffect)(() => {
|
|
1839
|
+
if (videoIdRef.current !== props.videoId) {
|
|
1840
|
+
videoIdRef.current = props.videoId;
|
|
1841
|
+
pendingSwitchRef.current = null;
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1844
|
+
const pending = pendingSwitchRef.current;
|
|
1845
|
+
if (!pending || !player) return;
|
|
1846
|
+
pendingSwitchRef.current = null;
|
|
1847
|
+
const generation = ++switchGenerationRef.current;
|
|
1848
|
+
player.updateConfig({
|
|
1849
|
+
player: {
|
|
1850
|
+
startPosition: pending.time > 0.25 ? pending.time : 0,
|
|
1851
|
+
startMuted: false,
|
|
1852
|
+
volume: pending.volume,
|
|
1853
|
+
autoplay: pending.playing
|
|
1854
|
+
}
|
|
1855
|
+
});
|
|
1856
|
+
void player.reload().then(() => {
|
|
1857
|
+
if (generation !== switchGenerationRef.current) return;
|
|
1858
|
+
try {
|
|
1859
|
+
if (!player.isLive()) {
|
|
1860
|
+
player.setPlaybackRate(pending.rate);
|
|
1861
|
+
if (pending.time > 0.25 && Math.abs(player.getCurrentTime() - pending.time) > 1.5) {
|
|
1862
|
+
player.seek(pending.time);
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
player.unmute();
|
|
1866
|
+
if (player.getVolume() <= 0) player.setVolume(pending.volume);
|
|
1867
|
+
if (pending.playing) void player.play();
|
|
1868
|
+
} catch {
|
|
1869
|
+
}
|
|
1870
|
+
});
|
|
1871
|
+
}, [player, props.mediaMode, props.videoId]);
|
|
1872
|
+
(0, import_react9.useEffect)(() => {
|
|
1520
1873
|
if (!player) return;
|
|
1521
1874
|
const report = () => {
|
|
1522
1875
|
const t = player.getCurrentTime();
|
|
@@ -1544,7 +1897,7 @@ var NsgVideoPlayerWithControls = (0, import_react8.forwardRef)(function NsgVideo
|
|
|
1544
1897
|
});
|
|
1545
1898
|
const cssVars = (0, import_video_nsgplayer_core2.themeToCssVars)(resolvedConfig.theme);
|
|
1546
1899
|
const showBootstrap = state === "loading" || state === "idle";
|
|
1547
|
-
return /* @__PURE__ */ (0,
|
|
1900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1548
1901
|
"div",
|
|
1549
1902
|
{
|
|
1550
1903
|
ref: containerRef,
|
|
@@ -1561,25 +1914,39 @@ var NsgVideoPlayerWithControls = (0, import_react8.forwardRef)(function NsgVideo
|
|
|
1561
1914
|
...props.style
|
|
1562
1915
|
},
|
|
1563
1916
|
children: [
|
|
1564
|
-
/* @__PURE__ */ (0,
|
|
1917
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1565
1918
|
PlayerChrome,
|
|
1566
1919
|
{
|
|
1567
1920
|
player,
|
|
1568
1921
|
config: resolvedConfig,
|
|
1569
1922
|
containerRef,
|
|
1570
1923
|
getSeekPreview: props.getSeekPreview,
|
|
1571
|
-
|
|
1924
|
+
mediaMode: props.mediaMode,
|
|
1925
|
+
audioAvailable: props.audioAvailable,
|
|
1926
|
+
onMediaModeChange: requestMediaMode,
|
|
1927
|
+
sidecarCaptions: props.sidecarCaptions,
|
|
1928
|
+
selectedSidecar: props.selectedSidecar,
|
|
1929
|
+
onSidecarChange: props.onSidecarChange,
|
|
1930
|
+
captionStatus: props.captionStatus,
|
|
1931
|
+
videoSlot: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1572
1932
|
"video",
|
|
1573
1933
|
{
|
|
1574
1934
|
ref: videoRef,
|
|
1575
1935
|
playsInline: true,
|
|
1576
1936
|
preload: "metadata",
|
|
1577
|
-
|
|
1937
|
+
poster: props.mediaMode === "audio" ? props.poster : void 0,
|
|
1938
|
+
style: {
|
|
1939
|
+
width: "100%",
|
|
1940
|
+
height: "100%",
|
|
1941
|
+
display: "block",
|
|
1942
|
+
objectFit: "contain",
|
|
1943
|
+
background: "#000"
|
|
1944
|
+
}
|
|
1578
1945
|
}
|
|
1579
1946
|
)
|
|
1580
1947
|
}
|
|
1581
1948
|
),
|
|
1582
|
-
watermark.visible ? /* @__PURE__ */ (0,
|
|
1949
|
+
watermark.visible ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1583
1950
|
"div",
|
|
1584
1951
|
{
|
|
1585
1952
|
className: "nsg-player-watermark",
|
|
@@ -1591,12 +1958,82 @@ var NsgVideoPlayerWithControls = (0, import_react8.forwardRef)(function NsgVideo
|
|
|
1591
1958
|
children: resolvedConfig.watermark.text
|
|
1592
1959
|
}
|
|
1593
1960
|
) : null,
|
|
1594
|
-
error ? /* @__PURE__ */ (0,
|
|
1595
|
-
showBootstrap && !error ? /* @__PURE__ */ (0,
|
|
1961
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "nsg-player-error", role: "alert", children: error.message || "Unable to play this video." }) : null,
|
|
1962
|
+
showBootstrap && !error ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "nsg-player-status", children: "Loading video\u2026" }) : null
|
|
1596
1963
|
]
|
|
1597
1964
|
}
|
|
1598
1965
|
);
|
|
1599
1966
|
});
|
|
1967
|
+
|
|
1968
|
+
// src/components/QualitySelector.tsx
|
|
1969
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1970
|
+
function QualitySelector({
|
|
1971
|
+
qualities,
|
|
1972
|
+
selection,
|
|
1973
|
+
activeLevel,
|
|
1974
|
+
onSelect
|
|
1975
|
+
}) {
|
|
1976
|
+
if (qualities.length <= 1) return null;
|
|
1977
|
+
const sorted = [...qualities].sort(
|
|
1978
|
+
(a, b) => b.height - a.height || b.bitrate - a.bitrate
|
|
1979
|
+
);
|
|
1980
|
+
const activeLabel = activeLevel >= 0 ? qualities.find((q) => q.index === activeLevel)?.label : void 0;
|
|
1981
|
+
const buttonLabel = selection === "auto" ? activeLabel ? `Auto (${activeLabel})` : "Auto" : qualities.find((q) => q.index === selection)?.label ?? "Quality";
|
|
1982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(PlayerMenu, { label: "Quality", buttonLabel, menuKind: "quality", children: [
|
|
1983
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1984
|
+
PlayerMenuItem,
|
|
1985
|
+
{
|
|
1986
|
+
active: selection === "auto",
|
|
1987
|
+
menuKind: "quality",
|
|
1988
|
+
onSelect: () => onSelect("auto"),
|
|
1989
|
+
children: [
|
|
1990
|
+
"Auto",
|
|
1991
|
+
activeLabel ? ` (${activeLabel})` : ""
|
|
1992
|
+
]
|
|
1993
|
+
}
|
|
1994
|
+
),
|
|
1995
|
+
sorted.map((level) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1996
|
+
PlayerMenuItem,
|
|
1997
|
+
{
|
|
1998
|
+
active: selection === level.index,
|
|
1999
|
+
menuKind: "quality",
|
|
2000
|
+
onSelect: () => onSelect(level.index),
|
|
2001
|
+
children: level.label
|
|
2002
|
+
},
|
|
2003
|
+
level.index
|
|
2004
|
+
))
|
|
2005
|
+
] });
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
// src/components/TextTrackSelector.tsx
|
|
2009
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2010
|
+
function TextTrackSelector({
|
|
2011
|
+
tracks,
|
|
2012
|
+
selection,
|
|
2013
|
+
onSelect
|
|
2014
|
+
}) {
|
|
2015
|
+
if (tracks.length === 0) return null;
|
|
2016
|
+
const buttonLabel = selection === "off" ? "CC" : tracks.find((t) => t.index === selection)?.label ?? "CC";
|
|
2017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(PlayerMenu, { label: "Captions", buttonLabel, children: [
|
|
2018
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2019
|
+
PlayerMenuItem,
|
|
2020
|
+
{
|
|
2021
|
+
active: selection === "off",
|
|
2022
|
+
onSelect: () => onSelect("off"),
|
|
2023
|
+
children: "Off"
|
|
2024
|
+
}
|
|
2025
|
+
),
|
|
2026
|
+
tracks.map((track) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2027
|
+
PlayerMenuItem,
|
|
2028
|
+
{
|
|
2029
|
+
active: selection === track.index,
|
|
2030
|
+
onSelect: () => onSelect(track.index),
|
|
2031
|
+
children: track.label
|
|
2032
|
+
},
|
|
2033
|
+
track.id
|
|
2034
|
+
))
|
|
2035
|
+
] });
|
|
2036
|
+
}
|
|
1600
2037
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1601
2038
|
0 && (module.exports = {
|
|
1602
2039
|
AudioTrackSelector,
|
|
@@ -1613,6 +2050,7 @@ var NsgVideoPlayerWithControls = (0, import_react8.forwardRef)(function NsgVideo
|
|
|
1613
2050
|
QUALITY_PREFERENCE_STORAGE_KEY,
|
|
1614
2051
|
QualitySelector,
|
|
1615
2052
|
SeekBar,
|
|
2053
|
+
SettingsMenu,
|
|
1616
2054
|
TextTrackSelector,
|
|
1617
2055
|
ZOOM_STEPS,
|
|
1618
2056
|
formatPlaybackTime,
|