@codenkay/video-nsgplayer-ui 5.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/dist/index.js CHANGED
@@ -3,10 +3,10 @@
3
3
  // src/NsgVideoPlayerWithControls.tsx
4
4
  import {
5
5
  forwardRef,
6
- useEffect as useEffect7,
6
+ useEffect as useEffect8,
7
7
  useImperativeHandle,
8
8
  useMemo as useMemo2,
9
- useRef as useRef6
9
+ useRef as useRef7
10
10
  } from "react";
11
11
  import {
12
12
  mergePlayerConfig,
@@ -17,9 +17,9 @@ import { useVideoPlayer } from "@codenkay/video-nsgplayer-react";
17
17
  // src/components/PlayerChrome.tsx
18
18
  import {
19
19
  useCallback as useCallback3,
20
- useEffect as useEffect5,
21
- useRef as useRef4,
22
- useState as useState5
20
+ useEffect as useEffect6,
21
+ useRef as useRef5,
22
+ useState as useState6
23
23
  } from "react";
24
24
 
25
25
  // src/hooks/usePlayerControls.ts
@@ -77,6 +77,7 @@ function snapPlaybackRate(rate, visible) {
77
77
  function resolvePlayerOverlay(input) {
78
78
  if (!input.showControls) return "none";
79
79
  if (!input.isPlaying) return "play";
80
+ if (input.mediaMode === "audio") return "return-video";
80
81
  if (input.muted || input.volume <= 0) return "unmute";
81
82
  return "none";
82
83
  }
@@ -368,6 +369,9 @@ function usePlayerControls(options) {
368
369
  const zoomOut = useCallback(() => {
369
370
  setZoom((prev) => nextZoom(prev, -1));
370
371
  }, []);
372
+ const setZoomLevel = useCallback((level) => {
373
+ setZoom(ZOOM_STEPS.includes(level) ? level : 1);
374
+ }, []);
371
375
  return {
372
376
  isPlaying,
373
377
  currentTime,
@@ -401,7 +405,8 @@ function usePlayerControls(options) {
401
405
  toggleFullscreen,
402
406
  goToLive,
403
407
  zoomIn,
404
- zoomOut
408
+ zoomOut,
409
+ setZoom: setZoomLevel
405
410
  };
406
411
  }
407
412
 
@@ -429,43 +434,53 @@ function PlayIconPreset({
429
434
  // src/components/PlayerCenterOverlay.tsx
430
435
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
431
436
  var ENABLE_AUDIO_PROMPT = "Tap to enable audio";
437
+ var ENABLE_VIDEO_PROMPT = "Tap to enable video";
432
438
  function PlayerCenterOverlay({
433
439
  kind,
434
440
  playIconPreset,
435
441
  onPlay,
436
- onEnableAudio
442
+ onEnableAudio,
443
+ onReturnToVideo
437
444
  }) {
438
445
  if (kind === "none") return null;
439
446
  const isPlay = kind === "play";
447
+ const isReturnVideo = kind === "return-video";
448
+ const label = isPlay ? "Play" : isReturnVideo ? ENABLE_VIDEO_PROMPT : ENABLE_AUDIO_PROMPT;
449
+ const activate = () => {
450
+ if (isPlay) onPlay();
451
+ else if (isReturnVideo) onReturnToVideo?.();
452
+ else onEnableAudio();
453
+ };
440
454
  return /* @__PURE__ */ jsx2(
441
455
  "div",
442
456
  {
443
457
  className: "nsg-player-center-overlay",
444
458
  onClick: (event) => {
445
459
  event.stopPropagation();
446
- if (isPlay) onPlay();
447
- else onEnableAudio();
460
+ activate();
448
461
  },
449
462
  children: /* @__PURE__ */ jsxs2(
450
463
  "button",
451
464
  {
452
465
  type: "button",
453
466
  className: "nsg-player-center-btn",
454
- "aria-label": isPlay ? "Play" : ENABLE_AUDIO_PROMPT,
467
+ "aria-label": label,
455
468
  onClick: (event) => {
456
469
  event.stopPropagation();
457
- if (isPlay) onPlay();
458
- else onEnableAudio();
470
+ activate();
459
471
  },
460
472
  children: [
461
- /* @__PURE__ */ jsx2("span", { className: "nsg-player-center-disc", children: isPlay ? /* @__PURE__ */ jsx2(PlayIconPreset, { preset: playIconPreset, size: 36 }) : /* @__PURE__ */ jsx2("svg", { width: "34", height: "34", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx2("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" }) }) }),
462
- isPlay ? null : /* @__PURE__ */ jsx2("span", { className: "nsg-player-center-label", children: ENABLE_AUDIO_PROMPT })
473
+ /* @__PURE__ */ jsx2("span", { className: "nsg-player-center-disc", children: isPlay ? /* @__PURE__ */ jsx2(PlayIconPreset, { preset: playIconPreset, size: 36 }) : isReturnVideo ? /* @__PURE__ */ jsx2(AudioModeGlyph, {}) : /* @__PURE__ */ jsx2("svg", { width: "34", height: "34", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx2("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" }) }) }),
474
+ isPlay ? null : /* @__PURE__ */ jsx2("span", { className: "nsg-player-center-label", children: label })
463
475
  ]
464
476
  }
465
477
  )
466
478
  }
467
479
  );
468
480
  }
481
+ function AudioModeGlyph() {
482
+ return /* @__PURE__ */ jsx2("svg", { width: "34", height: "34", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx2("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" }) });
483
+ }
469
484
 
470
485
  // src/components/PlayerMenu.tsx
471
486
  import {
@@ -691,53 +706,13 @@ function PlaybackSpeedSelector({
691
706
  )) });
692
707
  }
693
708
 
694
- // src/components/QualitySelector.tsx
695
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
696
- function QualitySelector({
697
- qualities,
698
- selection,
699
- activeLevel,
700
- onSelect
701
- }) {
702
- if (qualities.length <= 1) return null;
703
- const sorted = [...qualities].sort(
704
- (a, b) => b.height - a.height || b.bitrate - a.bitrate
705
- );
706
- const activeLabel = activeLevel >= 0 ? qualities.find((q) => q.index === activeLevel)?.label : void 0;
707
- const buttonLabel = selection === "auto" ? activeLabel ? `Auto (${activeLabel})` : "Auto" : qualities.find((q) => q.index === selection)?.label ?? "Quality";
708
- return /* @__PURE__ */ jsxs5(PlayerMenu, { label: "Quality", buttonLabel, menuKind: "quality", children: [
709
- /* @__PURE__ */ jsxs5(
710
- PlayerMenuItem,
711
- {
712
- active: selection === "auto",
713
- menuKind: "quality",
714
- onSelect: () => onSelect("auto"),
715
- children: [
716
- "Auto",
717
- activeLabel ? ` (${activeLabel})` : ""
718
- ]
719
- }
720
- ),
721
- sorted.map((level) => /* @__PURE__ */ jsx7(
722
- PlayerMenuItem,
723
- {
724
- active: selection === level.index,
725
- menuKind: "quality",
726
- onSelect: () => onSelect(level.index),
727
- children: level.label
728
- },
729
- level.index
730
- ))
731
- ] });
732
- }
733
-
734
709
  // src/components/SeekBar.tsx
735
710
  import {
736
711
  useCallback as useCallback2,
737
712
  useRef as useRef3,
738
713
  useState as useState4
739
714
  } from "react";
740
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
715
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
741
716
  var INITIAL_HOVER = {
742
717
  visible: false,
743
718
  time: 0,
@@ -797,7 +772,7 @@ function SeekBar({
797
772
  onSeek(max);
798
773
  }
799
774
  };
800
- return /* @__PURE__ */ jsxs6(
775
+ return /* @__PURE__ */ jsxs5(
801
776
  "div",
802
777
  {
803
778
  ref: trackRef,
@@ -808,28 +783,28 @@ function SeekBar({
808
783
  onPointerDown,
809
784
  role: "presentation",
810
785
  children: [
811
- /* @__PURE__ */ jsx8(
786
+ /* @__PURE__ */ jsx7(
812
787
  "div",
813
788
  {
814
789
  className: "nsg-player-seek__buffered",
815
790
  style: { width: `${bufferedPct}%` }
816
791
  }
817
792
  ),
818
- /* @__PURE__ */ jsx8(
793
+ /* @__PURE__ */ jsx7(
819
794
  "div",
820
795
  {
821
796
  className: "nsg-player-seek__played",
822
797
  style: { width: `${playedPct}%` }
823
798
  }
824
799
  ),
825
- hover.visible && max > 0 ? /* @__PURE__ */ jsxs6(
800
+ hover.visible && max > 0 ? /* @__PURE__ */ jsxs5(
826
801
  "div",
827
802
  {
828
803
  className: "nsg-player-seek__tooltip",
829
804
  style: { left: `${hover.percent}%` },
830
805
  role: "tooltip",
831
806
  children: [
832
- previewUrl ? /* @__PURE__ */ jsx8(
807
+ previewUrl ? /* @__PURE__ */ jsx7(
833
808
  "img",
834
809
  {
835
810
  className: "nsg-player-seek__preview",
@@ -842,7 +817,7 @@ function SeekBar({
842
817
  ]
843
818
  }
844
819
  ) : null,
845
- /* @__PURE__ */ jsx8(
820
+ /* @__PURE__ */ jsx7(
846
821
  "input",
847
822
  {
848
823
  ref: seekInputRef,
@@ -863,38 +838,273 @@ function SeekBar({
863
838
  );
864
839
  }
865
840
 
866
- // src/components/TextTrackSelector.tsx
867
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
868
- function TextTrackSelector({
869
- tracks,
870
- selection,
871
- onSelect
841
+ // src/components/SettingsMenu.tsx
842
+ import { useEffect as useEffect5, useId as useId3, useRef as useRef4, useState as useState5 } from "react";
843
+ import { Fragment, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
844
+ function SettingsMenu({
845
+ showQuality,
846
+ qualities,
847
+ qualitySelection,
848
+ activeLevel,
849
+ onQualityChange,
850
+ showZoom,
851
+ zoom,
852
+ onZoomChange,
853
+ captions,
854
+ selectedCaption,
855
+ onCaptionChange,
856
+ textTracks,
857
+ selectedTextTrack,
858
+ onTextTrackChange,
859
+ captionStatus
872
860
  }) {
873
- if (tracks.length === 0) return null;
874
- const buttonLabel = selection === "off" ? "CC" : tracks.find((t) => t.index === selection)?.label ?? "CC";
875
- return /* @__PURE__ */ jsxs7(PlayerMenu, { label: "Captions", buttonLabel, children: [
876
- /* @__PURE__ */ jsx9(
877
- PlayerMenuItem,
861
+ const [open, setOpen] = useState5(false);
862
+ const [panel, setPanel] = useState5("root");
863
+ const rootRef = useRef4(null);
864
+ const menuId = useId3();
865
+ const qualityLevels = showQuality && qualities.length > 1 ? [...qualities].sort((a, b) => b.height - a.height || b.bitrate - a.bitrate) : [];
866
+ const showQualityRow = qualityLevels.length > 0;
867
+ const showSubtitleRow = captions.length > 0 || textTracks.length > 0;
868
+ const showZoomRow = showZoom;
869
+ const hasRows = showQualityRow || showZoomRow || showSubtitleRow;
870
+ const activeQuality = activeLevel >= 0 ? qualities.find((level) => level.index === activeLevel)?.label : void 0;
871
+ const qualityValue = qualitySelection === "auto" ? activeQuality ? `Auto (${activeQuality})` : "Auto" : qualities.find((level) => level.index === qualitySelection)?.label ?? "Auto";
872
+ const captionValue = selectedCaption ? captions.find((track) => track.language === selectedCaption)?.label ?? "On" : selectedTextTrack === "off" ? "Off" : textTracks.find((track) => track.index === selectedTextTrack)?.label ?? "On";
873
+ useEffect5(() => {
874
+ if (!open) return;
875
+ const onPointerDown = (event) => {
876
+ if (!rootRef.current?.contains(event.target)) {
877
+ setOpen(false);
878
+ setPanel("root");
879
+ }
880
+ };
881
+ const onKeyDown = (event) => {
882
+ if (event.key === "Escape") {
883
+ setOpen(false);
884
+ setPanel("root");
885
+ }
886
+ };
887
+ document.addEventListener("mousedown", onPointerDown);
888
+ document.addEventListener("keydown", onKeyDown);
889
+ return () => {
890
+ document.removeEventListener("mousedown", onPointerDown);
891
+ document.removeEventListener("keydown", onKeyDown);
892
+ };
893
+ }, [open]);
894
+ if (!hasRows) return null;
895
+ const title = panel === "quality" ? "Quality" : panel === "zoom" ? "Zoom" : panel === "subtitles" ? "Subtitles" : "Settings";
896
+ return /* @__PURE__ */ jsxs6("div", { ref: rootRef, className: "nsg-player-menu", children: [
897
+ /* @__PURE__ */ jsx8(
898
+ "button",
878
899
  {
879
- active: selection === "off",
880
- onSelect: () => onSelect("off"),
881
- children: "Off"
900
+ type: "button",
901
+ className: "nsg-player-btn",
902
+ "aria-label": "Settings",
903
+ "aria-haspopup": "menu",
904
+ "aria-expanded": open,
905
+ "aria-controls": menuId,
906
+ onClick: (event) => {
907
+ event.stopPropagation();
908
+ setOpen((current) => {
909
+ if (current) setPanel("root");
910
+ return !current;
911
+ });
912
+ },
913
+ children: /* @__PURE__ */ jsx8(SettingsIcon, {})
882
914
  }
883
915
  ),
884
- tracks.map((track) => /* @__PURE__ */ jsx9(
885
- PlayerMenuItem,
916
+ open ? /* @__PURE__ */ jsx8(
917
+ "div",
886
918
  {
887
- active: selection === track.index,
888
- onSelect: () => onSelect(track.index),
889
- children: track.label
890
- },
891
- track.id
892
- ))
919
+ id: menuId,
920
+ role: "menu",
921
+ "aria-label": title,
922
+ className: "nsg-player-menu__panel nsg-player-settings",
923
+ onClick: (event) => event.stopPropagation(),
924
+ children: panel === "root" ? /* @__PURE__ */ jsxs6(Fragment, { children: [
925
+ showQualityRow ? /* @__PURE__ */ jsxs6(
926
+ "button",
927
+ {
928
+ type: "button",
929
+ role: "menuitem",
930
+ className: "nsg-player-menu__item nsg-player-settings__row",
931
+ onClick: () => setPanel("quality"),
932
+ children: [
933
+ /* @__PURE__ */ jsxs6("span", { className: "nsg-player-settings__name", children: [
934
+ /* @__PURE__ */ jsx8(QualityIcon, {}),
935
+ "Quality"
936
+ ] }),
937
+ /* @__PURE__ */ jsx8("span", { className: "nsg-player-settings__value", children: qualityValue })
938
+ ]
939
+ }
940
+ ) : null,
941
+ showZoomRow ? /* @__PURE__ */ jsxs6(
942
+ "button",
943
+ {
944
+ type: "button",
945
+ role: "menuitem",
946
+ className: "nsg-player-menu__item nsg-player-settings__row",
947
+ onClick: () => setPanel("zoom"),
948
+ children: [
949
+ /* @__PURE__ */ jsxs6("span", { className: "nsg-player-settings__name", children: [
950
+ /* @__PURE__ */ jsx8(ZoomIcon, {}),
951
+ "Zoom"
952
+ ] }),
953
+ /* @__PURE__ */ jsxs6("span", { className: "nsg-player-settings__value", children: [
954
+ zoom,
955
+ "\xD7"
956
+ ] })
957
+ ]
958
+ }
959
+ ) : null,
960
+ showSubtitleRow ? /* @__PURE__ */ jsxs6(
961
+ "button",
962
+ {
963
+ type: "button",
964
+ role: "menuitem",
965
+ className: "nsg-player-menu__item nsg-player-settings__row",
966
+ onClick: () => setPanel("subtitles"),
967
+ children: [
968
+ /* @__PURE__ */ jsxs6("span", { className: "nsg-player-settings__name", children: [
969
+ /* @__PURE__ */ jsx8(SubtitlesIcon, {}),
970
+ "Subtitles"
971
+ ] }),
972
+ /* @__PURE__ */ jsx8("span", { className: "nsg-player-settings__value", children: captionValue })
973
+ ]
974
+ }
975
+ ) : null
976
+ ] }) : /* @__PURE__ */ jsxs6(Fragment, { children: [
977
+ /* @__PURE__ */ jsxs6("div", { className: "nsg-player-settings__header", children: [
978
+ /* @__PURE__ */ jsx8(
979
+ "button",
980
+ {
981
+ type: "button",
982
+ className: "nsg-player-settings__back",
983
+ "aria-label": "Back",
984
+ onClick: () => setPanel("root"),
985
+ children: /* @__PURE__ */ jsx8(BackIcon, {})
986
+ }
987
+ ),
988
+ /* @__PURE__ */ jsx8("span", { children: title })
989
+ ] }),
990
+ panel === "quality" ? /* @__PURE__ */ jsxs6(Fragment, { children: [
991
+ /* @__PURE__ */ jsxs6(
992
+ Option,
993
+ {
994
+ active: qualitySelection === "auto",
995
+ onSelect: () => onQualityChange("auto"),
996
+ children: [
997
+ "Auto",
998
+ activeQuality ? ` (${activeQuality})` : ""
999
+ ]
1000
+ }
1001
+ ),
1002
+ qualityLevels.map((level) => /* @__PURE__ */ jsx8(
1003
+ Option,
1004
+ {
1005
+ active: qualitySelection === level.index,
1006
+ onSelect: () => onQualityChange(level.index),
1007
+ children: level.label
1008
+ },
1009
+ level.index
1010
+ ))
1011
+ ] }) : null,
1012
+ panel === "zoom" ? ZOOM_STEPS.map((level) => /* @__PURE__ */ jsxs6(
1013
+ Option,
1014
+ {
1015
+ active: zoom === level,
1016
+ onSelect: () => onZoomChange(level),
1017
+ children: [
1018
+ level,
1019
+ "\xD7"
1020
+ ]
1021
+ },
1022
+ level
1023
+ )) : null,
1024
+ panel === "subtitles" ? /* @__PURE__ */ jsxs6(Fragment, { children: [
1025
+ /* @__PURE__ */ jsx8(
1026
+ Option,
1027
+ {
1028
+ active: !selectedCaption && selectedTextTrack === "off",
1029
+ onSelect: () => {
1030
+ onCaptionChange?.(null);
1031
+ onTextTrackChange("off");
1032
+ },
1033
+ children: "Off"
1034
+ }
1035
+ ),
1036
+ captions.map((track) => /* @__PURE__ */ jsxs6(
1037
+ Option,
1038
+ {
1039
+ active: selectedCaption === track.language,
1040
+ onSelect: () => {
1041
+ onTextTrackChange("off");
1042
+ onCaptionChange?.(track.language);
1043
+ },
1044
+ children: [
1045
+ track.label,
1046
+ track.generated ? " (auto)" : ""
1047
+ ]
1048
+ },
1049
+ track.language
1050
+ )),
1051
+ captions.length === 0 ? textTracks.map((track) => /* @__PURE__ */ jsx8(
1052
+ Option,
1053
+ {
1054
+ active: selectedTextTrack === track.index,
1055
+ onSelect: () => onTextTrackChange(track.index),
1056
+ children: track.label
1057
+ },
1058
+ track.id
1059
+ )) : null,
1060
+ captionStatus ? /* @__PURE__ */ jsx8("p", { className: "nsg-player-settings__status", children: captionStatus }) : null
1061
+ ] }) : null
1062
+ ] })
1063
+ }
1064
+ ) : null
893
1065
  ] });
894
1066
  }
1067
+ function Option({
1068
+ active,
1069
+ children,
1070
+ onSelect
1071
+ }) {
1072
+ return /* @__PURE__ */ jsxs6(
1073
+ "button",
1074
+ {
1075
+ type: "button",
1076
+ role: "menuitemradio",
1077
+ "aria-checked": active,
1078
+ className: "nsg-player-menu__item nsg-player-settings__row",
1079
+ onClick: (event) => {
1080
+ event.stopPropagation();
1081
+ onSelect();
1082
+ },
1083
+ children: [
1084
+ /* @__PURE__ */ jsx8("span", { className: "nsg-player-settings__check", "aria-hidden": true, children: active ? "\u2713" : "" }),
1085
+ children
1086
+ ]
1087
+ }
1088
+ );
1089
+ }
1090
+ function QualityIcon() {
1091
+ return /* @__PURE__ */ jsx8("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx8("path", { d: "M4 6h16v10H4V6zm2 2v6h12V8H6zm3 10h6v2H9v-2z" }) });
1092
+ }
1093
+ function ZoomIcon() {
1094
+ return /* @__PURE__ */ jsx8("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx8("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" }) });
1095
+ }
1096
+ function SubtitlesIcon() {
1097
+ return /* @__PURE__ */ jsx8("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx8("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" }) });
1098
+ }
1099
+ function SettingsIcon() {
1100
+ return /* @__PURE__ */ jsx8("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx8("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" }) });
1101
+ }
1102
+ function BackIcon() {
1103
+ return /* @__PURE__ */ jsx8("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx8("path", { d: "M15.4 7.4 14 6l-6 6 6 6 1.4-1.4L10.8 12z" }) });
1104
+ }
895
1105
 
896
1106
  // src/components/PlayerControlBar.tsx
897
- import { Fragment, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1107
+ import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
898
1108
  function PlayerControlBar(props) {
899
1109
  const {
900
1110
  config,
@@ -927,22 +1137,36 @@ function PlayerControlBar(props) {
927
1137
  onTextTrackChange,
928
1138
  onAudioTrackChange,
929
1139
  onToggleFullscreen,
930
- onZoomIn,
931
- onZoomOut,
1140
+ onZoomChange,
932
1141
  seekBarRef,
933
- getSeekPreview
1142
+ getSeekPreview,
1143
+ mediaMode = "video",
1144
+ audioAvailable = false,
1145
+ onMediaModeChange,
1146
+ sidecarCaptions = [],
1147
+ selectedSidecar = null,
1148
+ onSidecarChange,
1149
+ captionStatus = null,
1150
+ onPointerEnter,
1151
+ onPointerLeave,
1152
+ onFocusCapture,
1153
+ onBlurCapture
934
1154
  } = props;
935
1155
  const controls = config.controls;
936
1156
  const showZoom = config.player.zoomEnabled && controls.showZoom;
937
1157
  const skipSeconds = config.player.skipSeconds;
938
- return /* @__PURE__ */ jsxs8(
1158
+ return /* @__PURE__ */ jsxs7(
939
1159
  "div",
940
1160
  {
941
1161
  className: "nsg-player-control-bar",
942
1162
  onClick: (event) => event.stopPropagation(),
943
1163
  onKeyDown: (event) => event.stopPropagation(),
1164
+ onPointerEnter,
1165
+ onPointerLeave,
1166
+ onFocusCapture,
1167
+ onBlurCapture,
944
1168
  children: [
945
- /* @__PURE__ */ jsx10(
1169
+ /* @__PURE__ */ jsx9(
946
1170
  SeekBar,
947
1171
  {
948
1172
  currentTime,
@@ -953,19 +1177,19 @@ function PlayerControlBar(props) {
953
1177
  getSeekPreview
954
1178
  }
955
1179
  ),
956
- /* @__PURE__ */ jsxs8("div", { className: "nsg-player-control-row", children: [
957
- /* @__PURE__ */ jsx10(
1180
+ /* @__PURE__ */ jsxs7("div", { className: "nsg-player-control-row", children: [
1181
+ /* @__PURE__ */ jsx9(
958
1182
  "button",
959
1183
  {
960
1184
  type: "button",
961
1185
  className: "nsg-player-btn",
962
1186
  "aria-label": isPlaying ? "Pause" : "Play",
963
1187
  onClick: onTogglePlay,
964
- children: isPlaying ? /* @__PURE__ */ jsx10(PauseIcon, {}) : /* @__PURE__ */ jsx10(PlayIcon, {})
1188
+ children: isPlaying ? /* @__PURE__ */ jsx9(PauseIcon, {}) : /* @__PURE__ */ jsx9(PlayIcon, {})
965
1189
  }
966
1190
  ),
967
- controls.showSkip ? /* @__PURE__ */ jsxs8(Fragment, { children: [
968
- /* @__PURE__ */ jsx10(
1191
+ controls.showSkip ? /* @__PURE__ */ jsxs7(Fragment2, { children: [
1192
+ /* @__PURE__ */ jsx9(
969
1193
  "button",
970
1194
  {
971
1195
  type: "button",
@@ -973,10 +1197,10 @@ function PlayerControlBar(props) {
973
1197
  style: { color: "var(--player-skip-icon)" },
974
1198
  "aria-label": `Back ${skipSeconds} seconds`,
975
1199
  onClick: () => onSkip("backward"),
976
- children: /* @__PURE__ */ jsx10(SkipIcon, { label: String(skipSeconds), forward: false })
1200
+ children: /* @__PURE__ */ jsx9(SkipIcon, { label: String(skipSeconds), forward: false })
977
1201
  }
978
1202
  ),
979
- /* @__PURE__ */ jsx10(
1203
+ /* @__PURE__ */ jsx9(
980
1204
  "button",
981
1205
  {
982
1206
  type: "button",
@@ -984,12 +1208,12 @@ function PlayerControlBar(props) {
984
1208
  style: { color: "var(--player-skip-icon)" },
985
1209
  "aria-label": `Forward ${skipSeconds} seconds`,
986
1210
  onClick: () => onSkip("forward"),
987
- children: /* @__PURE__ */ jsx10(SkipIcon, { label: String(skipSeconds), forward: true })
1211
+ children: /* @__PURE__ */ jsx9(SkipIcon, { label: String(skipSeconds), forward: true })
988
1212
  }
989
1213
  )
990
1214
  ] }) : null,
991
- controls.showVolume ? /* @__PURE__ */ jsxs8("div", { className: "nsg-player-volume", children: [
992
- /* @__PURE__ */ jsx10(
1215
+ controls.showVolume ? /* @__PURE__ */ jsxs7("div", { className: "nsg-player-volume", children: [
1216
+ /* @__PURE__ */ jsx9(
993
1217
  "button",
994
1218
  {
995
1219
  type: "button",
@@ -997,10 +1221,10 @@ function PlayerControlBar(props) {
997
1221
  style: { color: "var(--player-volume-icon)" },
998
1222
  "aria-label": muted || volume === 0 ? "Unmute" : "Mute",
999
1223
  onClick: onToggleMute,
1000
- children: muted || volume === 0 ? /* @__PURE__ */ jsx10(MuteIcon, {}) : /* @__PURE__ */ jsx10(VolumeIcon, {})
1224
+ children: muted || volume === 0 ? /* @__PURE__ */ jsx9(MuteIcon, {}) : /* @__PURE__ */ jsx9(VolumeIcon, {})
1001
1225
  }
1002
1226
  ),
1003
- /* @__PURE__ */ jsx10(
1227
+ /* @__PURE__ */ jsx9(
1004
1228
  "input",
1005
1229
  {
1006
1230
  type: "range",
@@ -1014,53 +1238,25 @@ function PlayerControlBar(props) {
1014
1238
  }
1015
1239
  )
1016
1240
  ] }) : null,
1017
- /* @__PURE__ */ jsxs8("span", { className: "nsg-player-time", children: [
1241
+ /* @__PURE__ */ jsxs7("span", { className: "nsg-player-time", children: [
1018
1242
  formatPlaybackTime(currentTime),
1019
1243
  " / ",
1020
1244
  formatPlaybackTime(duration)
1021
1245
  ] }),
1022
- controls.showLive && isLive ? /* @__PURE__ */ jsx10(LiveBadgeButton, { atLiveEdge, onGoToLive }) : null,
1023
- /* @__PURE__ */ jsxs8("div", { className: "nsg-player-control-row-end", children: [
1024
- showZoom ? /* @__PURE__ */ jsxs8(
1025
- "div",
1246
+ controls.showLive && isLive ? /* @__PURE__ */ jsx9(LiveBadgeButton, { atLiveEdge, onGoToLive }) : null,
1247
+ /* @__PURE__ */ jsxs7("div", { className: "nsg-player-control-row-end", children: [
1248
+ onMediaModeChange && audioAvailable ? /* @__PURE__ */ jsx9(
1249
+ "button",
1026
1250
  {
1027
- className: "nsg-player-zoom",
1028
- role: "group",
1029
- "aria-label": `Zoom ${zoom}\xD7`,
1030
- children: [
1031
- /* @__PURE__ */ jsxs8("span", { className: "nsg-player-zoom__label", children: [
1032
- "Zoom ",
1033
- /* @__PURE__ */ jsxs8("span", { style: { fontVariantNumeric: "tabular-nums" }, children: [
1034
- zoom,
1035
- "\xD7"
1036
- ] })
1037
- ] }),
1038
- /* @__PURE__ */ jsx10(
1039
- "button",
1040
- {
1041
- type: "button",
1042
- className: "nsg-player-btn",
1043
- "aria-label": `Zoom out (current ${zoom}\xD7)`,
1044
- disabled: zoom <= 1,
1045
- onClick: onZoomOut,
1046
- children: "\u2212"
1047
- }
1048
- ),
1049
- /* @__PURE__ */ jsx10(
1050
- "button",
1051
- {
1052
- type: "button",
1053
- className: "nsg-player-btn",
1054
- "aria-label": `Zoom in (current ${zoom}\xD7)`,
1055
- disabled: zoom >= 2,
1056
- onClick: onZoomIn,
1057
- children: "+"
1058
- }
1059
- )
1060
- ]
1251
+ type: "button",
1252
+ className: "nsg-player-btn",
1253
+ "aria-label": mediaMode === "audio" ? "Switch to video" : "Listen to audio",
1254
+ "aria-pressed": mediaMode === "audio",
1255
+ onClick: () => onMediaModeChange(mediaMode === "audio" ? "video" : "audio"),
1256
+ children: /* @__PURE__ */ jsx9(AudioModeIcon, { active: mediaMode === "audio" })
1061
1257
  }
1062
1258
  ) : null,
1063
- controls.showSpeed && !isLive ? /* @__PURE__ */ jsx10(
1259
+ controls.showSpeed && !isLive ? /* @__PURE__ */ jsx9(
1064
1260
  PlaybackSpeedSelector,
1065
1261
  {
1066
1262
  rate: playbackRate,
@@ -1068,24 +1264,27 @@ function PlayerControlBar(props) {
1068
1264
  onSelect: onPlaybackRateChange
1069
1265
  }
1070
1266
  ) : null,
1071
- controls.showQuality ? /* @__PURE__ */ jsx10(
1072
- QualitySelector,
1267
+ /* @__PURE__ */ jsx9(
1268
+ SettingsMenu,
1073
1269
  {
1270
+ showQuality: controls.showQuality && mediaMode !== "audio",
1074
1271
  qualities,
1075
- selection: qualitySelection,
1272
+ qualitySelection,
1076
1273
  activeLevel,
1077
- onSelect: onQualityChange
1078
- }
1079
- ) : null,
1080
- controls.showCaptions ? /* @__PURE__ */ jsx10(
1081
- TextTrackSelector,
1082
- {
1083
- tracks: textTracks,
1084
- selection: selectedTextTrack,
1085
- onSelect: onTextTrackChange
1274
+ onQualityChange,
1275
+ showZoom,
1276
+ zoom,
1277
+ onZoomChange,
1278
+ captions: mediaMode === "audio" ? [] : sidecarCaptions,
1279
+ selectedCaption: selectedSidecar,
1280
+ onCaptionChange: onSidecarChange,
1281
+ textTracks: controls.showCaptions && mediaMode !== "audio" ? textTracks : [],
1282
+ selectedTextTrack,
1283
+ onTextTrackChange,
1284
+ captionStatus
1086
1285
  }
1087
- ) : null,
1088
- controls.showAudio ? /* @__PURE__ */ jsx10(
1286
+ ),
1287
+ controls.showAudio && mediaMode !== "audio" ? /* @__PURE__ */ jsx9(
1089
1288
  AudioTrackSelector,
1090
1289
  {
1091
1290
  tracks: audioTracks,
@@ -1093,7 +1292,7 @@ function PlayerControlBar(props) {
1093
1292
  onSelect: onAudioTrackChange
1094
1293
  }
1095
1294
  ) : null,
1096
- controls.showFullscreen ? /* @__PURE__ */ jsx10(
1295
+ controls.showFullscreen ? /* @__PURE__ */ jsx9(
1097
1296
  "button",
1098
1297
  {
1099
1298
  type: "button",
@@ -1109,27 +1308,40 @@ function PlayerControlBar(props) {
1109
1308
  }
1110
1309
  );
1111
1310
  }
1311
+ function AudioModeIcon({ active }) {
1312
+ return /* @__PURE__ */ jsx9(
1313
+ "svg",
1314
+ {
1315
+ width: "18",
1316
+ height: "18",
1317
+ viewBox: "0 0 24 24",
1318
+ fill: active ? "var(--player-quality-active-text, currentColor)" : "currentColor",
1319
+ "aria-hidden": true,
1320
+ children: /* @__PURE__ */ jsx9("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" })
1321
+ }
1322
+ );
1323
+ }
1112
1324
  function PlayIcon() {
1113
- return /* @__PURE__ */ jsx10("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx10("path", { d: "M8 5v14l11-7z" }) });
1325
+ return /* @__PURE__ */ jsx9("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx9("path", { d: "M8 5v14l11-7z" }) });
1114
1326
  }
1115
1327
  function PauseIcon() {
1116
- return /* @__PURE__ */ jsx10("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx10("path", { d: "M6 5h4v14H6zm8 0h4v14h-4z" }) });
1328
+ return /* @__PURE__ */ jsx9("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx9("path", { d: "M6 5h4v14H6zm8 0h4v14h-4z" }) });
1117
1329
  }
1118
1330
  function SkipIcon({ label, forward }) {
1119
- return /* @__PURE__ */ jsxs8("span", { style: { display: "flex", flexDirection: "column", alignItems: "center", lineHeight: 1 }, children: [
1120
- /* @__PURE__ */ jsx10("svg", { width: "16", height: "14", viewBox: "0 0 24 16", fill: "currentColor", "aria-hidden": true, children: forward ? /* @__PURE__ */ jsx10("path", { d: "M3 2v12l9-6-9-6zm9 0v12l9-6-9-6z" }) : /* @__PURE__ */ jsx10("path", { d: "M12 2v12L3 8l9-6zm9 0v12l-9-6 9-6z" }) }),
1121
- /* @__PURE__ */ jsx10("span", { style: { fontSize: 9, fontWeight: 700 }, children: label })
1331
+ return /* @__PURE__ */ jsxs7("span", { style: { display: "flex", flexDirection: "column", alignItems: "center", lineHeight: 1 }, children: [
1332
+ /* @__PURE__ */ jsx9("svg", { width: "16", height: "14", viewBox: "0 0 24 16", fill: "currentColor", "aria-hidden": true, children: forward ? /* @__PURE__ */ jsx9("path", { d: "M3 2v12l9-6-9-6zm9 0v12l9-6-9-6z" }) : /* @__PURE__ */ jsx9("path", { d: "M12 2v12L3 8l9-6zm9 0v12l-9-6 9-6z" }) }),
1333
+ /* @__PURE__ */ jsx9("span", { style: { fontSize: 9, fontWeight: 700 }, children: label })
1122
1334
  ] });
1123
1335
  }
1124
1336
  function VolumeIcon() {
1125
- return /* @__PURE__ */ jsx10("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx10("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" }) });
1337
+ return /* @__PURE__ */ jsx9("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx9("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" }) });
1126
1338
  }
1127
1339
  function MuteIcon() {
1128
- return /* @__PURE__ */ jsx10("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx10("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" }) });
1340
+ return /* @__PURE__ */ jsx9("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx9("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" }) });
1129
1341
  }
1130
1342
 
1131
1343
  // src/components/PlayerSkipCue.tsx
1132
- import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
1344
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1133
1345
  function PlayerSkipCue({
1134
1346
  direction,
1135
1347
  cueId,
@@ -1138,14 +1350,14 @@ function PlayerSkipCue({
1138
1350
  if (!direction) return null;
1139
1351
  const isForward = direction === "forward";
1140
1352
  const label = isForward ? `+${seconds}` : `-${seconds}`;
1141
- return /* @__PURE__ */ jsx11(
1353
+ return /* @__PURE__ */ jsx10(
1142
1354
  "div",
1143
1355
  {
1144
1356
  className: `nsg-player-skip-cue ${isForward ? "nsg-player-skip-cue--forward" : "nsg-player-skip-cue--backward"}`,
1145
1357
  "aria-hidden": true,
1146
- children: /* @__PURE__ */ jsxs9("div", { className: "nsg-player-skip-cue-badge", children: [
1147
- /* @__PURE__ */ jsx11("span", { className: "nsg-player-skip-cue-disc", children: isForward ? /* @__PURE__ */ jsx11("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx11("path", { d: "M3 6v12l8.5-6L3 6zm9 0v12l8.5-6L12 6z" }) }) : /* @__PURE__ */ jsx11("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx11("path", { d: "M11.5 12 20 6v12l-8.5-6zm-8.5 0L11 6v12L3 12z" }) }) }),
1148
- /* @__PURE__ */ jsx11("span", { style: { fontSize: "1.125rem", fontWeight: 600 }, children: label })
1358
+ children: /* @__PURE__ */ jsxs8("div", { className: "nsg-player-skip-cue-badge", children: [
1359
+ /* @__PURE__ */ jsx10("span", { className: "nsg-player-skip-cue-disc", children: isForward ? /* @__PURE__ */ jsx10("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx10("path", { d: "M3 6v12l8.5-6L3 6zm9 0v12l8.5-6L12 6z" }) }) : /* @__PURE__ */ jsx10("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx10("path", { d: "M11.5 12 20 6v12l-8.5-6zm-8.5 0L11 6v12L3 12z" }) }) }),
1360
+ /* @__PURE__ */ jsx10("span", { style: { fontSize: "1.125rem", fontWeight: 600 }, children: label })
1149
1361
  ] })
1150
1362
  },
1151
1363
  cueId
@@ -1153,29 +1365,85 @@ function PlayerSkipCue({
1153
1365
  }
1154
1366
 
1155
1367
  // src/components/PlayerChrome.tsx
1156
- import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1368
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
1157
1369
  function PlayerChrome({
1158
1370
  player,
1159
1371
  config,
1160
1372
  containerRef,
1161
1373
  videoSlot,
1162
1374
  className,
1163
- getSeekPreview
1375
+ getSeekPreview,
1376
+ mediaMode,
1377
+ audioAvailable,
1378
+ onMediaModeChange,
1379
+ sidecarCaptions,
1380
+ selectedSidecar,
1381
+ onSidecarChange,
1382
+ captionStatus
1164
1383
  }) {
1165
- const rootRef = useRef4(null);
1166
- const seekBarRef = useRef4(null);
1167
- const skipCueTimerRef = useRef4(null);
1168
- const [skipCue, setSkipCue] = useState5(null);
1384
+ const rootRef = useRef5(null);
1385
+ const seekBarRef = useRef5(null);
1386
+ const skipCueTimerRef = useRef5(null);
1387
+ const [skipCue, setSkipCue] = useState6(null);
1169
1388
  const controls = usePlayerControls({
1170
1389
  player,
1171
1390
  config,
1172
1391
  containerRef
1173
1392
  });
1393
+ const TOOLBAR_IDLE_MS = 5e3;
1394
+ const [toolbarVisible, setToolbarVisible] = useState6(true);
1395
+ const toolbarVisibleRef = useRef5(true);
1396
+ const controlsPinnedRef = useRef5(false);
1397
+ const idleTimerRef = useRef5(null);
1398
+ const clearToolbarIdle = useCallback3(() => {
1399
+ if (idleTimerRef.current) {
1400
+ window.clearTimeout(idleTimerRef.current);
1401
+ idleTimerRef.current = null;
1402
+ }
1403
+ }, []);
1404
+ const scheduleToolbarHide = useCallback3(() => {
1405
+ clearToolbarIdle();
1406
+ idleTimerRef.current = window.setTimeout(() => {
1407
+ if (controlsPinnedRef.current) return;
1408
+ toolbarVisibleRef.current = false;
1409
+ setToolbarVisible(false);
1410
+ }, TOOLBAR_IDLE_MS);
1411
+ }, [clearToolbarIdle]);
1412
+ const revealToolbar = useCallback3(() => {
1413
+ if (!toolbarVisibleRef.current) {
1414
+ toolbarVisibleRef.current = true;
1415
+ setToolbarVisible(true);
1416
+ }
1417
+ if (!controlsPinnedRef.current) scheduleToolbarHide();
1418
+ }, [scheduleToolbarHide]);
1419
+ useEffect6(() => {
1420
+ if (!controls.showControls) {
1421
+ clearToolbarIdle();
1422
+ toolbarVisibleRef.current = false;
1423
+ setToolbarVisible(false);
1424
+ return;
1425
+ }
1426
+ revealToolbar();
1427
+ return clearToolbarIdle;
1428
+ }, [controls.showControls, revealToolbar, clearToolbarIdle]);
1429
+ const pinToolbar = useCallback3(() => {
1430
+ controlsPinnedRef.current = true;
1431
+ clearToolbarIdle();
1432
+ if (!toolbarVisibleRef.current) {
1433
+ toolbarVisibleRef.current = true;
1434
+ setToolbarVisible(true);
1435
+ }
1436
+ }, [clearToolbarIdle]);
1437
+ const releaseToolbar = useCallback3(() => {
1438
+ controlsPinnedRef.current = false;
1439
+ scheduleToolbarHide();
1440
+ }, [scheduleToolbarHide]);
1174
1441
  const overlay = resolvePlayerOverlay({
1175
1442
  showControls: controls.showControls,
1176
1443
  isPlaying: controls.isPlaying,
1177
1444
  muted: controls.muted,
1178
- volume: controls.volume
1445
+ volume: controls.volume,
1446
+ mediaMode
1179
1447
  });
1180
1448
  const flashSkipCue = useCallback3(
1181
1449
  (direction) => {
@@ -1202,21 +1470,23 @@ function PlayerChrome({
1202
1470
  flashSkipCue
1203
1471
  ]
1204
1472
  );
1205
- useEffect5(() => {
1473
+ useEffect6(() => {
1206
1474
  return () => {
1207
1475
  if (skipCueTimerRef.current) window.clearTimeout(skipCueTimerRef.current);
1208
1476
  };
1209
1477
  }, []);
1210
- useEffect5(() => {
1478
+ useEffect6(() => {
1211
1479
  const root = rootRef.current;
1212
- if (!root || !controls.showControls || !config.controls.keyboardShortcuts) {
1480
+ if (!root || !controls.showControls) {
1213
1481
  return;
1214
1482
  }
1215
1483
  const onKeyDown = (event) => {
1484
+ revealToolbar();
1216
1485
  const target = event.target;
1217
1486
  if (target && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable)) {
1218
1487
  return;
1219
1488
  }
1489
+ if (!config.controls.keyboardShortcuts) return;
1220
1490
  switch (event.key) {
1221
1491
  case " ":
1222
1492
  case "k":
@@ -1273,17 +1543,20 @@ function PlayerChrome({
1273
1543
  root.tabIndex = 0;
1274
1544
  root.addEventListener("keydown", onKeyDown);
1275
1545
  return () => root.removeEventListener("keydown", onKeyDown);
1276
- }, [controls, config, skip]);
1277
- return /* @__PURE__ */ jsxs10(
1546
+ }, [controls, config, skip, revealToolbar]);
1547
+ return /* @__PURE__ */ jsxs9(
1278
1548
  "div",
1279
1549
  {
1280
1550
  ref: rootRef,
1281
1551
  className: ["nsg-player-root", className].filter(Boolean).join(" "),
1282
1552
  role: "region",
1283
1553
  "aria-label": "Video player",
1554
+ onPointerEnter: controls.showControls ? revealToolbar : void 0,
1555
+ onPointerMove: controls.showControls ? revealToolbar : void 0,
1556
+ onPointerDown: controls.showControls ? revealToolbar : void 0,
1284
1557
  onClick: controls.showControls ? controls.togglePlay : void 0,
1285
1558
  children: [
1286
- /* @__PURE__ */ jsx12(
1559
+ /* @__PURE__ */ jsx11(
1287
1560
  "div",
1288
1561
  {
1289
1562
  className: "nsg-player-video-wrap",
@@ -1291,16 +1564,17 @@ function PlayerChrome({
1291
1564
  children: videoSlot
1292
1565
  }
1293
1566
  ),
1294
- /* @__PURE__ */ jsx12(
1567
+ /* @__PURE__ */ jsx11(
1295
1568
  PlayerCenterOverlay,
1296
1569
  {
1297
1570
  kind: overlay,
1298
1571
  playIconPreset: config.theme.playIconPreset,
1299
1572
  onPlay: controls.togglePlay,
1300
- onEnableAudio: controls.enableAudio
1573
+ onEnableAudio: controls.enableAudio,
1574
+ onReturnToVideo: () => onMediaModeChange?.("video")
1301
1575
  }
1302
1576
  ),
1303
- /* @__PURE__ */ jsx12(
1577
+ /* @__PURE__ */ jsx11(
1304
1578
  PlayerSkipCue,
1305
1579
  {
1306
1580
  direction: skipCue?.direction ?? null,
@@ -1309,7 +1583,7 @@ function PlayerChrome({
1309
1583
  },
1310
1584
  skipCue?.id ?? "idle"
1311
1585
  ),
1312
- controls.showControls ? /* @__PURE__ */ jsx12(
1586
+ controls.showControls && toolbarVisible ? /* @__PURE__ */ jsx11(
1313
1587
  PlayerControlBar,
1314
1588
  {
1315
1589
  config,
@@ -1342,19 +1616,42 @@ function PlayerChrome({
1342
1616
  onTextTrackChange: controls.setTextTrack,
1343
1617
  onAudioTrackChange: controls.setAudioTrack,
1344
1618
  onToggleFullscreen: () => void controls.toggleFullscreen(),
1345
- onZoomIn: controls.zoomIn,
1346
- onZoomOut: controls.zoomOut,
1619
+ onZoomChange: controls.setZoom,
1347
1620
  seekBarRef,
1348
- getSeekPreview
1621
+ mediaMode,
1622
+ audioAvailable,
1623
+ onMediaModeChange,
1624
+ sidecarCaptions,
1625
+ selectedSidecar,
1626
+ onSidecarChange,
1627
+ captionStatus,
1628
+ getSeekPreview,
1629
+ onPointerEnter: pinToolbar,
1630
+ onPointerLeave: releaseToolbar,
1631
+ onFocusCapture: pinToolbar,
1632
+ onBlurCapture: (event) => {
1633
+ const next = event.relatedTarget;
1634
+ if (next instanceof Node && event.currentTarget.contains(next)) return;
1635
+ releaseToolbar();
1636
+ }
1349
1637
  }
1350
- ) : null
1638
+ ) : null,
1639
+ controls.showControls && !toolbarVisible && Number.isFinite(controls.duration) && controls.duration > 0 ? /* @__PURE__ */ jsx11("div", { className: "nsg-player-edge-progress", "aria-hidden": true, children: /* @__PURE__ */ jsx11(
1640
+ "div",
1641
+ {
1642
+ className: "nsg-player-edge-progress__played",
1643
+ style: {
1644
+ width: `${Math.min(100, controls.currentTime / controls.duration * 100)}%`
1645
+ }
1646
+ }
1647
+ ) }) : null
1351
1648
  ]
1352
1649
  }
1353
1650
  );
1354
1651
  }
1355
1652
 
1356
1653
  // src/hooks/usePlaybackWatermark.ts
1357
- import { useEffect as useEffect6, useRef as useRef5, useState as useState6 } from "react";
1654
+ import { useEffect as useEffect7, useRef as useRef6, useState as useState7 } from "react";
1358
1655
 
1359
1656
  // src/utils/watermarkSchedule.ts
1360
1657
  var WATERMARK_TOP_MIN_PCT = 8;
@@ -1404,11 +1701,11 @@ function usePlaybackWatermark({
1404
1701
  intervalMaxMs,
1405
1702
  reducedMotion = false
1406
1703
  }) {
1407
- const [state, setState] = useState6(HIDDEN);
1408
- const showTimerRef = useRef5(null);
1409
- const hideTimerRef = useRef5(null);
1410
- const generationRef = useRef5(0);
1411
- useEffect6(() => {
1704
+ const [state, setState] = useState7(HIDDEN);
1705
+ const showTimerRef = useRef6(null);
1706
+ const hideTimerRef = useRef6(null);
1707
+ const generationRef = useRef6(0);
1708
+ useEffect7(() => {
1412
1709
  const clearTimers = () => {
1413
1710
  if (showTimerRef.current !== null) {
1414
1711
  window.clearTimeout(showTimerRef.current);
@@ -1460,11 +1757,14 @@ function usePlaybackWatermark({
1460
1757
  }
1461
1758
 
1462
1759
  // src/NsgVideoPlayerWithControls.tsx
1463
- import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
1760
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1464
1761
  var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2(props, ref) {
1465
- const containerRef = useRef6(null);
1466
- const onWatchTimeRef = useRef6(props.onWatchTime);
1762
+ const containerRef = useRef7(null);
1763
+ const onWatchTimeRef = useRef7(props.onWatchTime);
1467
1764
  onWatchTimeRef.current = props.onWatchTime;
1765
+ const pendingSwitchRef = useRef7(null);
1766
+ const switchGenerationRef = useRef7(0);
1767
+ const videoIdRef = useRef7(props.videoId);
1468
1768
  const resolvedConfig = useMemo2(
1469
1769
  () => mergePlayerConfig({
1470
1770
  ...props.config,
@@ -1489,7 +1789,59 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
1489
1789
  onAuthError: props.onAuthError
1490
1790
  });
1491
1791
  useImperativeHandle(ref, () => player, [player]);
1492
- useEffect7(() => {
1792
+ const requestMediaMode = (mode) => {
1793
+ if (mode === (props.mediaMode ?? "video")) return;
1794
+ const volume = player?.getVolume() ?? 1;
1795
+ const audible = volume > 0 ? volume : 1;
1796
+ const video = videoRef.current;
1797
+ if (video) {
1798
+ video.muted = false;
1799
+ video.volume = audible;
1800
+ }
1801
+ const playbackState = player?.getState();
1802
+ pendingSwitchRef.current = {
1803
+ time: player?.getCurrentTime() ?? 0,
1804
+ rate: player?.getPlaybackRate() ?? 1,
1805
+ volume: audible,
1806
+ playing: playbackState === "playing" || playbackState === "buffering"
1807
+ };
1808
+ props.onMediaModeChange?.(mode);
1809
+ };
1810
+ useEffect8(() => {
1811
+ if (videoIdRef.current !== props.videoId) {
1812
+ videoIdRef.current = props.videoId;
1813
+ pendingSwitchRef.current = null;
1814
+ return;
1815
+ }
1816
+ const pending = pendingSwitchRef.current;
1817
+ if (!pending || !player) return;
1818
+ pendingSwitchRef.current = null;
1819
+ const generation = ++switchGenerationRef.current;
1820
+ player.updateConfig({
1821
+ player: {
1822
+ startPosition: pending.time > 0.25 ? pending.time : 0,
1823
+ startMuted: false,
1824
+ volume: pending.volume,
1825
+ autoplay: pending.playing
1826
+ }
1827
+ });
1828
+ void player.reload().then(() => {
1829
+ if (generation !== switchGenerationRef.current) return;
1830
+ try {
1831
+ if (!player.isLive()) {
1832
+ player.setPlaybackRate(pending.rate);
1833
+ if (pending.time > 0.25 && Math.abs(player.getCurrentTime() - pending.time) > 1.5) {
1834
+ player.seek(pending.time);
1835
+ }
1836
+ }
1837
+ player.unmute();
1838
+ if (player.getVolume() <= 0) player.setVolume(pending.volume);
1839
+ if (pending.playing) void player.play();
1840
+ } catch {
1841
+ }
1842
+ });
1843
+ }, [player, props.mediaMode, props.videoId]);
1844
+ useEffect8(() => {
1493
1845
  if (!player) return;
1494
1846
  const report = () => {
1495
1847
  const t = player.getCurrentTime();
@@ -1517,7 +1869,7 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
1517
1869
  });
1518
1870
  const cssVars = themeToCssVars(resolvedConfig.theme);
1519
1871
  const showBootstrap = state === "loading" || state === "idle";
1520
- return /* @__PURE__ */ jsxs11(
1872
+ return /* @__PURE__ */ jsxs10(
1521
1873
  "div",
1522
1874
  {
1523
1875
  ref: containerRef,
@@ -1534,25 +1886,39 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
1534
1886
  ...props.style
1535
1887
  },
1536
1888
  children: [
1537
- /* @__PURE__ */ jsx13(
1889
+ /* @__PURE__ */ jsx12(
1538
1890
  PlayerChrome,
1539
1891
  {
1540
1892
  player,
1541
1893
  config: resolvedConfig,
1542
1894
  containerRef,
1543
1895
  getSeekPreview: props.getSeekPreview,
1544
- videoSlot: /* @__PURE__ */ jsx13(
1896
+ mediaMode: props.mediaMode,
1897
+ audioAvailable: props.audioAvailable,
1898
+ onMediaModeChange: requestMediaMode,
1899
+ sidecarCaptions: props.sidecarCaptions,
1900
+ selectedSidecar: props.selectedSidecar,
1901
+ onSidecarChange: props.onSidecarChange,
1902
+ captionStatus: props.captionStatus,
1903
+ videoSlot: /* @__PURE__ */ jsx12(
1545
1904
  "video",
1546
1905
  {
1547
1906
  ref: videoRef,
1548
1907
  playsInline: true,
1549
1908
  preload: "metadata",
1550
- style: { width: "100%", height: "100%", display: "block" }
1909
+ poster: props.mediaMode === "audio" ? props.poster : void 0,
1910
+ style: {
1911
+ width: "100%",
1912
+ height: "100%",
1913
+ display: "block",
1914
+ objectFit: "contain",
1915
+ background: "#000"
1916
+ }
1551
1917
  }
1552
1918
  )
1553
1919
  }
1554
1920
  ),
1555
- watermark.visible ? /* @__PURE__ */ jsx13(
1921
+ watermark.visible ? /* @__PURE__ */ jsx12(
1556
1922
  "div",
1557
1923
  {
1558
1924
  className: "nsg-player-watermark",
@@ -1564,12 +1930,82 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
1564
1930
  children: resolvedConfig.watermark.text
1565
1931
  }
1566
1932
  ) : null,
1567
- error ? /* @__PURE__ */ jsx13("p", { className: "nsg-player-error", role: "alert", children: error.message || "Unable to play this video." }) : null,
1568
- showBootstrap && !error ? /* @__PURE__ */ jsx13("p", { className: "nsg-player-status", children: "Loading video\u2026" }) : null
1933
+ error ? /* @__PURE__ */ jsx12("p", { className: "nsg-player-error", role: "alert", children: error.message || "Unable to play this video." }) : null,
1934
+ showBootstrap && !error ? /* @__PURE__ */ jsx12("p", { className: "nsg-player-status", children: "Loading video\u2026" }) : null
1569
1935
  ]
1570
1936
  }
1571
1937
  );
1572
1938
  });
1939
+
1940
+ // src/components/QualitySelector.tsx
1941
+ import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
1942
+ function QualitySelector({
1943
+ qualities,
1944
+ selection,
1945
+ activeLevel,
1946
+ onSelect
1947
+ }) {
1948
+ if (qualities.length <= 1) return null;
1949
+ const sorted = [...qualities].sort(
1950
+ (a, b) => b.height - a.height || b.bitrate - a.bitrate
1951
+ );
1952
+ const activeLabel = activeLevel >= 0 ? qualities.find((q) => q.index === activeLevel)?.label : void 0;
1953
+ const buttonLabel = selection === "auto" ? activeLabel ? `Auto (${activeLabel})` : "Auto" : qualities.find((q) => q.index === selection)?.label ?? "Quality";
1954
+ return /* @__PURE__ */ jsxs11(PlayerMenu, { label: "Quality", buttonLabel, menuKind: "quality", children: [
1955
+ /* @__PURE__ */ jsxs11(
1956
+ PlayerMenuItem,
1957
+ {
1958
+ active: selection === "auto",
1959
+ menuKind: "quality",
1960
+ onSelect: () => onSelect("auto"),
1961
+ children: [
1962
+ "Auto",
1963
+ activeLabel ? ` (${activeLabel})` : ""
1964
+ ]
1965
+ }
1966
+ ),
1967
+ sorted.map((level) => /* @__PURE__ */ jsx13(
1968
+ PlayerMenuItem,
1969
+ {
1970
+ active: selection === level.index,
1971
+ menuKind: "quality",
1972
+ onSelect: () => onSelect(level.index),
1973
+ children: level.label
1974
+ },
1975
+ level.index
1976
+ ))
1977
+ ] });
1978
+ }
1979
+
1980
+ // src/components/TextTrackSelector.tsx
1981
+ import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
1982
+ function TextTrackSelector({
1983
+ tracks,
1984
+ selection,
1985
+ onSelect
1986
+ }) {
1987
+ if (tracks.length === 0) return null;
1988
+ const buttonLabel = selection === "off" ? "CC" : tracks.find((t) => t.index === selection)?.label ?? "CC";
1989
+ return /* @__PURE__ */ jsxs12(PlayerMenu, { label: "Captions", buttonLabel, children: [
1990
+ /* @__PURE__ */ jsx14(
1991
+ PlayerMenuItem,
1992
+ {
1993
+ active: selection === "off",
1994
+ onSelect: () => onSelect("off"),
1995
+ children: "Off"
1996
+ }
1997
+ ),
1998
+ tracks.map((track) => /* @__PURE__ */ jsx14(
1999
+ PlayerMenuItem,
2000
+ {
2001
+ active: selection === track.index,
2002
+ onSelect: () => onSelect(track.index),
2003
+ children: track.label
2004
+ },
2005
+ track.id
2006
+ ))
2007
+ ] });
2008
+ }
1573
2009
  export {
1574
2010
  AudioTrackSelector,
1575
2011
  LiveBadgeButton,
@@ -1585,6 +2021,7 @@ export {
1585
2021
  QUALITY_PREFERENCE_STORAGE_KEY,
1586
2022
  QualitySelector,
1587
2023
  SeekBar,
2024
+ SettingsMenu,
1588
2025
  TextTrackSelector,
1589
2026
  ZOOM_STEPS,
1590
2027
  formatPlaybackTime,