@codenkay/video-nsgplayer-ui 5.0.0 → 5.3.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 useEffect9,
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,10 +405,38 @@ 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
 
413
+ // src/utils/edgeProgress.ts
414
+ function edgeProgressPercent(input) {
415
+ const { currentTime, duration, bufferedEnd, isLive, atLiveEdge } = input;
416
+ if (Number.isFinite(duration) && duration > 0) {
417
+ return Math.min(100, Math.max(0, currentTime / duration * 100));
418
+ }
419
+ if (isLive) {
420
+ if (atLiveEdge) {
421
+ return 100;
422
+ }
423
+ if (Number.isFinite(bufferedEnd) && bufferedEnd > 0) {
424
+ return Math.min(100, Math.max(0, currentTime / bufferedEnd * 100));
425
+ }
426
+ return 100;
427
+ }
428
+ return 0;
429
+ }
430
+ function canShowEdgeProgress(input) {
431
+ if (!input.showControls || input.toolbarVisible) {
432
+ return false;
433
+ }
434
+ if (input.isLive) {
435
+ return true;
436
+ }
437
+ return Number.isFinite(input.duration) && input.duration > 0;
438
+ }
439
+
408
440
  // src/components/PlayIconPreset.tsx
409
441
  import { jsx, jsxs } from "react/jsx-runtime";
410
442
  function PlayIconPreset({
@@ -429,43 +461,53 @@ function PlayIconPreset({
429
461
  // src/components/PlayerCenterOverlay.tsx
430
462
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
431
463
  var ENABLE_AUDIO_PROMPT = "Tap to enable audio";
464
+ var ENABLE_VIDEO_PROMPT = "Tap to enable video";
432
465
  function PlayerCenterOverlay({
433
466
  kind,
434
467
  playIconPreset,
435
468
  onPlay,
436
- onEnableAudio
469
+ onEnableAudio,
470
+ onReturnToVideo
437
471
  }) {
438
472
  if (kind === "none") return null;
439
473
  const isPlay = kind === "play";
474
+ const isReturnVideo = kind === "return-video";
475
+ const label = isPlay ? "Play" : isReturnVideo ? ENABLE_VIDEO_PROMPT : ENABLE_AUDIO_PROMPT;
476
+ const activate = () => {
477
+ if (isPlay) onPlay();
478
+ else if (isReturnVideo) onReturnToVideo?.();
479
+ else onEnableAudio();
480
+ };
440
481
  return /* @__PURE__ */ jsx2(
441
482
  "div",
442
483
  {
443
484
  className: "nsg-player-center-overlay",
444
485
  onClick: (event) => {
445
486
  event.stopPropagation();
446
- if (isPlay) onPlay();
447
- else onEnableAudio();
487
+ activate();
448
488
  },
449
489
  children: /* @__PURE__ */ jsxs2(
450
490
  "button",
451
491
  {
452
492
  type: "button",
453
493
  className: "nsg-player-center-btn",
454
- "aria-label": isPlay ? "Play" : ENABLE_AUDIO_PROMPT,
494
+ "aria-label": label,
455
495
  onClick: (event) => {
456
496
  event.stopPropagation();
457
- if (isPlay) onPlay();
458
- else onEnableAudio();
497
+ activate();
459
498
  },
460
499
  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 })
500
+ /* @__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" }) }) }),
501
+ isPlay ? null : /* @__PURE__ */ jsx2("span", { className: "nsg-player-center-label", children: label })
463
502
  ]
464
503
  }
465
504
  )
466
505
  }
467
506
  );
468
507
  }
508
+ function AudioModeGlyph() {
509
+ 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" }) });
510
+ }
469
511
 
470
512
  // src/components/PlayerMenu.tsx
471
513
  import {
@@ -691,53 +733,13 @@ function PlaybackSpeedSelector({
691
733
  )) });
692
734
  }
693
735
 
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
736
  // src/components/SeekBar.tsx
735
737
  import {
736
738
  useCallback as useCallback2,
737
739
  useRef as useRef3,
738
740
  useState as useState4
739
741
  } from "react";
740
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
742
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
741
743
  var INITIAL_HOVER = {
742
744
  visible: false,
743
745
  time: 0,
@@ -797,7 +799,7 @@ function SeekBar({
797
799
  onSeek(max);
798
800
  }
799
801
  };
800
- return /* @__PURE__ */ jsxs6(
802
+ return /* @__PURE__ */ jsxs5(
801
803
  "div",
802
804
  {
803
805
  ref: trackRef,
@@ -808,28 +810,28 @@ function SeekBar({
808
810
  onPointerDown,
809
811
  role: "presentation",
810
812
  children: [
811
- /* @__PURE__ */ jsx8(
813
+ /* @__PURE__ */ jsx7(
812
814
  "div",
813
815
  {
814
816
  className: "nsg-player-seek__buffered",
815
817
  style: { width: `${bufferedPct}%` }
816
818
  }
817
819
  ),
818
- /* @__PURE__ */ jsx8(
820
+ /* @__PURE__ */ jsx7(
819
821
  "div",
820
822
  {
821
823
  className: "nsg-player-seek__played",
822
824
  style: { width: `${playedPct}%` }
823
825
  }
824
826
  ),
825
- hover.visible && max > 0 ? /* @__PURE__ */ jsxs6(
827
+ hover.visible && max > 0 ? /* @__PURE__ */ jsxs5(
826
828
  "div",
827
829
  {
828
830
  className: "nsg-player-seek__tooltip",
829
831
  style: { left: `${hover.percent}%` },
830
832
  role: "tooltip",
831
833
  children: [
832
- previewUrl ? /* @__PURE__ */ jsx8(
834
+ previewUrl ? /* @__PURE__ */ jsx7(
833
835
  "img",
834
836
  {
835
837
  className: "nsg-player-seek__preview",
@@ -842,7 +844,7 @@ function SeekBar({
842
844
  ]
843
845
  }
844
846
  ) : null,
845
- /* @__PURE__ */ jsx8(
847
+ /* @__PURE__ */ jsx7(
846
848
  "input",
847
849
  {
848
850
  ref: seekInputRef,
@@ -863,38 +865,273 @@ function SeekBar({
863
865
  );
864
866
  }
865
867
 
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
868
+ // src/components/SettingsMenu.tsx
869
+ import { useEffect as useEffect5, useId as useId3, useRef as useRef4, useState as useState5 } from "react";
870
+ import { Fragment, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
871
+ function SettingsMenu({
872
+ showQuality,
873
+ qualities,
874
+ qualitySelection,
875
+ activeLevel,
876
+ onQualityChange,
877
+ showZoom,
878
+ zoom,
879
+ onZoomChange,
880
+ captions,
881
+ selectedCaption,
882
+ onCaptionChange,
883
+ textTracks,
884
+ selectedTextTrack,
885
+ onTextTrackChange,
886
+ captionStatus
872
887
  }) {
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,
888
+ const [open, setOpen] = useState5(false);
889
+ const [panel, setPanel] = useState5("root");
890
+ const rootRef = useRef4(null);
891
+ const menuId = useId3();
892
+ const qualityLevels = showQuality && qualities.length > 1 ? [...qualities].sort((a, b) => b.height - a.height || b.bitrate - a.bitrate) : [];
893
+ const showQualityRow = qualityLevels.length > 0;
894
+ const showSubtitleRow = captions.length > 0 || textTracks.length > 0;
895
+ const showZoomRow = showZoom;
896
+ const hasRows = showQualityRow || showZoomRow || showSubtitleRow;
897
+ const activeQuality = activeLevel >= 0 ? qualities.find((level) => level.index === activeLevel)?.label : void 0;
898
+ const qualityValue = qualitySelection === "auto" ? activeQuality ? `Auto (${activeQuality})` : "Auto" : qualities.find((level) => level.index === qualitySelection)?.label ?? "Auto";
899
+ const captionValue = selectedCaption ? captions.find((track) => track.language === selectedCaption)?.label ?? "On" : selectedTextTrack === "off" ? "Off" : textTracks.find((track) => track.index === selectedTextTrack)?.label ?? "On";
900
+ useEffect5(() => {
901
+ if (!open) return;
902
+ const onPointerDown = (event) => {
903
+ if (!rootRef.current?.contains(event.target)) {
904
+ setOpen(false);
905
+ setPanel("root");
906
+ }
907
+ };
908
+ const onKeyDown = (event) => {
909
+ if (event.key === "Escape") {
910
+ setOpen(false);
911
+ setPanel("root");
912
+ }
913
+ };
914
+ document.addEventListener("mousedown", onPointerDown);
915
+ document.addEventListener("keydown", onKeyDown);
916
+ return () => {
917
+ document.removeEventListener("mousedown", onPointerDown);
918
+ document.removeEventListener("keydown", onKeyDown);
919
+ };
920
+ }, [open]);
921
+ if (!hasRows) return null;
922
+ const title = panel === "quality" ? "Quality" : panel === "zoom" ? "Zoom" : panel === "subtitles" ? "Subtitles" : "Settings";
923
+ return /* @__PURE__ */ jsxs6("div", { ref: rootRef, className: "nsg-player-menu", children: [
924
+ /* @__PURE__ */ jsx8(
925
+ "button",
878
926
  {
879
- active: selection === "off",
880
- onSelect: () => onSelect("off"),
881
- children: "Off"
927
+ type: "button",
928
+ className: "nsg-player-btn",
929
+ "aria-label": "Settings",
930
+ "aria-haspopup": "menu",
931
+ "aria-expanded": open,
932
+ "aria-controls": menuId,
933
+ onClick: (event) => {
934
+ event.stopPropagation();
935
+ setOpen((current) => {
936
+ if (current) setPanel("root");
937
+ return !current;
938
+ });
939
+ },
940
+ children: /* @__PURE__ */ jsx8(SettingsIcon, {})
882
941
  }
883
942
  ),
884
- tracks.map((track) => /* @__PURE__ */ jsx9(
885
- PlayerMenuItem,
943
+ open ? /* @__PURE__ */ jsx8(
944
+ "div",
886
945
  {
887
- active: selection === track.index,
888
- onSelect: () => onSelect(track.index),
889
- children: track.label
890
- },
891
- track.id
892
- ))
946
+ id: menuId,
947
+ role: "menu",
948
+ "aria-label": title,
949
+ className: "nsg-player-menu__panel nsg-player-settings",
950
+ onClick: (event) => event.stopPropagation(),
951
+ children: panel === "root" ? /* @__PURE__ */ jsxs6(Fragment, { children: [
952
+ showQualityRow ? /* @__PURE__ */ jsxs6(
953
+ "button",
954
+ {
955
+ type: "button",
956
+ role: "menuitem",
957
+ className: "nsg-player-menu__item nsg-player-settings__row",
958
+ onClick: () => setPanel("quality"),
959
+ children: [
960
+ /* @__PURE__ */ jsxs6("span", { className: "nsg-player-settings__name", children: [
961
+ /* @__PURE__ */ jsx8(QualityIcon, {}),
962
+ "Quality"
963
+ ] }),
964
+ /* @__PURE__ */ jsx8("span", { className: "nsg-player-settings__value", children: qualityValue })
965
+ ]
966
+ }
967
+ ) : null,
968
+ showZoomRow ? /* @__PURE__ */ jsxs6(
969
+ "button",
970
+ {
971
+ type: "button",
972
+ role: "menuitem",
973
+ className: "nsg-player-menu__item nsg-player-settings__row",
974
+ onClick: () => setPanel("zoom"),
975
+ children: [
976
+ /* @__PURE__ */ jsxs6("span", { className: "nsg-player-settings__name", children: [
977
+ /* @__PURE__ */ jsx8(ZoomIcon, {}),
978
+ "Zoom"
979
+ ] }),
980
+ /* @__PURE__ */ jsxs6("span", { className: "nsg-player-settings__value", children: [
981
+ zoom,
982
+ "\xD7"
983
+ ] })
984
+ ]
985
+ }
986
+ ) : null,
987
+ showSubtitleRow ? /* @__PURE__ */ jsxs6(
988
+ "button",
989
+ {
990
+ type: "button",
991
+ role: "menuitem",
992
+ className: "nsg-player-menu__item nsg-player-settings__row",
993
+ onClick: () => setPanel("subtitles"),
994
+ children: [
995
+ /* @__PURE__ */ jsxs6("span", { className: "nsg-player-settings__name", children: [
996
+ /* @__PURE__ */ jsx8(SubtitlesIcon, {}),
997
+ "Subtitles"
998
+ ] }),
999
+ /* @__PURE__ */ jsx8("span", { className: "nsg-player-settings__value", children: captionValue })
1000
+ ]
1001
+ }
1002
+ ) : null
1003
+ ] }) : /* @__PURE__ */ jsxs6(Fragment, { children: [
1004
+ /* @__PURE__ */ jsxs6("div", { className: "nsg-player-settings__header", children: [
1005
+ /* @__PURE__ */ jsx8(
1006
+ "button",
1007
+ {
1008
+ type: "button",
1009
+ className: "nsg-player-settings__back",
1010
+ "aria-label": "Back",
1011
+ onClick: () => setPanel("root"),
1012
+ children: /* @__PURE__ */ jsx8(BackIcon, {})
1013
+ }
1014
+ ),
1015
+ /* @__PURE__ */ jsx8("span", { children: title })
1016
+ ] }),
1017
+ panel === "quality" ? /* @__PURE__ */ jsxs6(Fragment, { children: [
1018
+ /* @__PURE__ */ jsxs6(
1019
+ Option,
1020
+ {
1021
+ active: qualitySelection === "auto",
1022
+ onSelect: () => onQualityChange("auto"),
1023
+ children: [
1024
+ "Auto",
1025
+ activeQuality ? ` (${activeQuality})` : ""
1026
+ ]
1027
+ }
1028
+ ),
1029
+ qualityLevels.map((level) => /* @__PURE__ */ jsx8(
1030
+ Option,
1031
+ {
1032
+ active: qualitySelection === level.index,
1033
+ onSelect: () => onQualityChange(level.index),
1034
+ children: level.label
1035
+ },
1036
+ level.index
1037
+ ))
1038
+ ] }) : null,
1039
+ panel === "zoom" ? ZOOM_STEPS.map((level) => /* @__PURE__ */ jsxs6(
1040
+ Option,
1041
+ {
1042
+ active: zoom === level,
1043
+ onSelect: () => onZoomChange(level),
1044
+ children: [
1045
+ level,
1046
+ "\xD7"
1047
+ ]
1048
+ },
1049
+ level
1050
+ )) : null,
1051
+ panel === "subtitles" ? /* @__PURE__ */ jsxs6(Fragment, { children: [
1052
+ /* @__PURE__ */ jsx8(
1053
+ Option,
1054
+ {
1055
+ active: !selectedCaption && selectedTextTrack === "off",
1056
+ onSelect: () => {
1057
+ onCaptionChange?.(null);
1058
+ onTextTrackChange("off");
1059
+ },
1060
+ children: "Off"
1061
+ }
1062
+ ),
1063
+ captions.map((track) => /* @__PURE__ */ jsxs6(
1064
+ Option,
1065
+ {
1066
+ active: selectedCaption === track.language,
1067
+ onSelect: () => {
1068
+ onTextTrackChange("off");
1069
+ onCaptionChange?.(track.language);
1070
+ },
1071
+ children: [
1072
+ track.label,
1073
+ track.generated ? " (auto)" : ""
1074
+ ]
1075
+ },
1076
+ track.language
1077
+ )),
1078
+ captions.length === 0 ? textTracks.map((track) => /* @__PURE__ */ jsx8(
1079
+ Option,
1080
+ {
1081
+ active: selectedTextTrack === track.index,
1082
+ onSelect: () => onTextTrackChange(track.index),
1083
+ children: track.label
1084
+ },
1085
+ track.id
1086
+ )) : null,
1087
+ captionStatus ? /* @__PURE__ */ jsx8("p", { className: "nsg-player-settings__status", children: captionStatus }) : null
1088
+ ] }) : null
1089
+ ] })
1090
+ }
1091
+ ) : null
893
1092
  ] });
894
1093
  }
1094
+ function Option({
1095
+ active,
1096
+ children,
1097
+ onSelect
1098
+ }) {
1099
+ return /* @__PURE__ */ jsxs6(
1100
+ "button",
1101
+ {
1102
+ type: "button",
1103
+ role: "menuitemradio",
1104
+ "aria-checked": active,
1105
+ className: "nsg-player-menu__item nsg-player-settings__row",
1106
+ onClick: (event) => {
1107
+ event.stopPropagation();
1108
+ onSelect();
1109
+ },
1110
+ children: [
1111
+ /* @__PURE__ */ jsx8("span", { className: "nsg-player-settings__check", "aria-hidden": true, children: active ? "\u2713" : "" }),
1112
+ children
1113
+ ]
1114
+ }
1115
+ );
1116
+ }
1117
+ function QualityIcon() {
1118
+ 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" }) });
1119
+ }
1120
+ function ZoomIcon() {
1121
+ 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" }) });
1122
+ }
1123
+ function SubtitlesIcon() {
1124
+ 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" }) });
1125
+ }
1126
+ function SettingsIcon() {
1127
+ 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" }) });
1128
+ }
1129
+ function BackIcon() {
1130
+ 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" }) });
1131
+ }
895
1132
 
896
1133
  // src/components/PlayerControlBar.tsx
897
- import { Fragment, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1134
+ import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
898
1135
  function PlayerControlBar(props) {
899
1136
  const {
900
1137
  config,
@@ -927,22 +1164,36 @@ function PlayerControlBar(props) {
927
1164
  onTextTrackChange,
928
1165
  onAudioTrackChange,
929
1166
  onToggleFullscreen,
930
- onZoomIn,
931
- onZoomOut,
1167
+ onZoomChange,
932
1168
  seekBarRef,
933
- getSeekPreview
1169
+ getSeekPreview,
1170
+ mediaMode = "video",
1171
+ audioAvailable = false,
1172
+ onMediaModeChange,
1173
+ sidecarCaptions = [],
1174
+ selectedSidecar = null,
1175
+ onSidecarChange,
1176
+ captionStatus = null,
1177
+ onPointerEnter,
1178
+ onPointerLeave,
1179
+ onFocusCapture,
1180
+ onBlurCapture
934
1181
  } = props;
935
1182
  const controls = config.controls;
936
1183
  const showZoom = config.player.zoomEnabled && controls.showZoom;
937
1184
  const skipSeconds = config.player.skipSeconds;
938
- return /* @__PURE__ */ jsxs8(
1185
+ return /* @__PURE__ */ jsxs7(
939
1186
  "div",
940
1187
  {
941
1188
  className: "nsg-player-control-bar",
942
1189
  onClick: (event) => event.stopPropagation(),
943
1190
  onKeyDown: (event) => event.stopPropagation(),
1191
+ onPointerEnter,
1192
+ onPointerLeave,
1193
+ onFocusCapture,
1194
+ onBlurCapture,
944
1195
  children: [
945
- /* @__PURE__ */ jsx10(
1196
+ /* @__PURE__ */ jsx9(
946
1197
  SeekBar,
947
1198
  {
948
1199
  currentTime,
@@ -953,19 +1204,19 @@ function PlayerControlBar(props) {
953
1204
  getSeekPreview
954
1205
  }
955
1206
  ),
956
- /* @__PURE__ */ jsxs8("div", { className: "nsg-player-control-row", children: [
957
- /* @__PURE__ */ jsx10(
1207
+ /* @__PURE__ */ jsxs7("div", { className: "nsg-player-control-row", children: [
1208
+ /* @__PURE__ */ jsx9(
958
1209
  "button",
959
1210
  {
960
1211
  type: "button",
961
1212
  className: "nsg-player-btn",
962
1213
  "aria-label": isPlaying ? "Pause" : "Play",
963
1214
  onClick: onTogglePlay,
964
- children: isPlaying ? /* @__PURE__ */ jsx10(PauseIcon, {}) : /* @__PURE__ */ jsx10(PlayIcon, {})
1215
+ children: isPlaying ? /* @__PURE__ */ jsx9(PauseIcon, {}) : /* @__PURE__ */ jsx9(PlayIcon, {})
965
1216
  }
966
1217
  ),
967
- controls.showSkip ? /* @__PURE__ */ jsxs8(Fragment, { children: [
968
- /* @__PURE__ */ jsx10(
1218
+ controls.showSkip ? /* @__PURE__ */ jsxs7(Fragment2, { children: [
1219
+ /* @__PURE__ */ jsx9(
969
1220
  "button",
970
1221
  {
971
1222
  type: "button",
@@ -973,10 +1224,10 @@ function PlayerControlBar(props) {
973
1224
  style: { color: "var(--player-skip-icon)" },
974
1225
  "aria-label": `Back ${skipSeconds} seconds`,
975
1226
  onClick: () => onSkip("backward"),
976
- children: /* @__PURE__ */ jsx10(SkipIcon, { label: String(skipSeconds), forward: false })
1227
+ children: /* @__PURE__ */ jsx9(SkipIcon, { label: String(skipSeconds), forward: false })
977
1228
  }
978
1229
  ),
979
- /* @__PURE__ */ jsx10(
1230
+ /* @__PURE__ */ jsx9(
980
1231
  "button",
981
1232
  {
982
1233
  type: "button",
@@ -984,12 +1235,12 @@ function PlayerControlBar(props) {
984
1235
  style: { color: "var(--player-skip-icon)" },
985
1236
  "aria-label": `Forward ${skipSeconds} seconds`,
986
1237
  onClick: () => onSkip("forward"),
987
- children: /* @__PURE__ */ jsx10(SkipIcon, { label: String(skipSeconds), forward: true })
1238
+ children: /* @__PURE__ */ jsx9(SkipIcon, { label: String(skipSeconds), forward: true })
988
1239
  }
989
1240
  )
990
1241
  ] }) : null,
991
- controls.showVolume ? /* @__PURE__ */ jsxs8("div", { className: "nsg-player-volume", children: [
992
- /* @__PURE__ */ jsx10(
1242
+ controls.showVolume ? /* @__PURE__ */ jsxs7("div", { className: "nsg-player-volume", children: [
1243
+ /* @__PURE__ */ jsx9(
993
1244
  "button",
994
1245
  {
995
1246
  type: "button",
@@ -997,10 +1248,10 @@ function PlayerControlBar(props) {
997
1248
  style: { color: "var(--player-volume-icon)" },
998
1249
  "aria-label": muted || volume === 0 ? "Unmute" : "Mute",
999
1250
  onClick: onToggleMute,
1000
- children: muted || volume === 0 ? /* @__PURE__ */ jsx10(MuteIcon, {}) : /* @__PURE__ */ jsx10(VolumeIcon, {})
1251
+ children: muted || volume === 0 ? /* @__PURE__ */ jsx9(MuteIcon, {}) : /* @__PURE__ */ jsx9(VolumeIcon, {})
1001
1252
  }
1002
1253
  ),
1003
- /* @__PURE__ */ jsx10(
1254
+ /* @__PURE__ */ jsx9(
1004
1255
  "input",
1005
1256
  {
1006
1257
  type: "range",
@@ -1014,53 +1265,25 @@ function PlayerControlBar(props) {
1014
1265
  }
1015
1266
  )
1016
1267
  ] }) : null,
1017
- /* @__PURE__ */ jsxs8("span", { className: "nsg-player-time", children: [
1268
+ /* @__PURE__ */ jsxs7("span", { className: "nsg-player-time", children: [
1018
1269
  formatPlaybackTime(currentTime),
1019
1270
  " / ",
1020
1271
  formatPlaybackTime(duration)
1021
1272
  ] }),
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",
1273
+ controls.showLive && isLive ? /* @__PURE__ */ jsx9(LiveBadgeButton, { atLiveEdge, onGoToLive }) : null,
1274
+ /* @__PURE__ */ jsxs7("div", { className: "nsg-player-control-row-end", children: [
1275
+ onMediaModeChange && audioAvailable ? /* @__PURE__ */ jsx9(
1276
+ "button",
1026
1277
  {
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
- ]
1278
+ type: "button",
1279
+ className: "nsg-player-btn",
1280
+ "aria-label": mediaMode === "audio" ? "Switch to video" : "Listen to audio",
1281
+ "aria-pressed": mediaMode === "audio",
1282
+ onClick: () => onMediaModeChange(mediaMode === "audio" ? "video" : "audio"),
1283
+ children: /* @__PURE__ */ jsx9(AudioModeIcon, { active: mediaMode === "audio" })
1061
1284
  }
1062
1285
  ) : null,
1063
- controls.showSpeed && !isLive ? /* @__PURE__ */ jsx10(
1286
+ controls.showSpeed && !isLive ? /* @__PURE__ */ jsx9(
1064
1287
  PlaybackSpeedSelector,
1065
1288
  {
1066
1289
  rate: playbackRate,
@@ -1068,24 +1291,27 @@ function PlayerControlBar(props) {
1068
1291
  onSelect: onPlaybackRateChange
1069
1292
  }
1070
1293
  ) : null,
1071
- controls.showQuality ? /* @__PURE__ */ jsx10(
1072
- QualitySelector,
1294
+ /* @__PURE__ */ jsx9(
1295
+ SettingsMenu,
1073
1296
  {
1297
+ showQuality: controls.showQuality && mediaMode !== "audio",
1074
1298
  qualities,
1075
- selection: qualitySelection,
1299
+ qualitySelection,
1076
1300
  activeLevel,
1077
- onSelect: onQualityChange
1301
+ onQualityChange,
1302
+ showZoom,
1303
+ zoom,
1304
+ onZoomChange,
1305
+ captions: mediaMode === "audio" ? [] : sidecarCaptions,
1306
+ selectedCaption: selectedSidecar,
1307
+ onCaptionChange: onSidecarChange,
1308
+ textTracks: controls.showCaptions && mediaMode !== "audio" ? textTracks : [],
1309
+ selectedTextTrack,
1310
+ onTextTrackChange,
1311
+ captionStatus
1078
1312
  }
1079
- ) : null,
1080
- controls.showCaptions ? /* @__PURE__ */ jsx10(
1081
- TextTrackSelector,
1082
- {
1083
- tracks: textTracks,
1084
- selection: selectedTextTrack,
1085
- onSelect: onTextTrackChange
1086
- }
1087
- ) : null,
1088
- controls.showAudio ? /* @__PURE__ */ jsx10(
1313
+ ),
1314
+ controls.showAudio && mediaMode !== "audio" ? /* @__PURE__ */ jsx9(
1089
1315
  AudioTrackSelector,
1090
1316
  {
1091
1317
  tracks: audioTracks,
@@ -1093,7 +1319,7 @@ function PlayerControlBar(props) {
1093
1319
  onSelect: onAudioTrackChange
1094
1320
  }
1095
1321
  ) : null,
1096
- controls.showFullscreen ? /* @__PURE__ */ jsx10(
1322
+ controls.showFullscreen ? /* @__PURE__ */ jsx9(
1097
1323
  "button",
1098
1324
  {
1099
1325
  type: "button",
@@ -1109,27 +1335,40 @@ function PlayerControlBar(props) {
1109
1335
  }
1110
1336
  );
1111
1337
  }
1338
+ function AudioModeIcon({ active }) {
1339
+ return /* @__PURE__ */ jsx9(
1340
+ "svg",
1341
+ {
1342
+ width: "18",
1343
+ height: "18",
1344
+ viewBox: "0 0 24 24",
1345
+ fill: active ? "var(--player-quality-active-text, currentColor)" : "currentColor",
1346
+ "aria-hidden": true,
1347
+ 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" })
1348
+ }
1349
+ );
1350
+ }
1112
1351
  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" }) });
1352
+ 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
1353
  }
1115
1354
  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" }) });
1355
+ 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
1356
  }
1118
1357
  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 })
1358
+ return /* @__PURE__ */ jsxs7("span", { style: { display: "flex", flexDirection: "column", alignItems: "center", lineHeight: 1 }, children: [
1359
+ /* @__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" }) }),
1360
+ /* @__PURE__ */ jsx9("span", { style: { fontSize: 9, fontWeight: 700 }, children: label })
1122
1361
  ] });
1123
1362
  }
1124
1363
  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" }) });
1364
+ 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
1365
  }
1127
1366
  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" }) });
1367
+ 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
1368
  }
1130
1369
 
1131
1370
  // src/components/PlayerSkipCue.tsx
1132
- import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
1371
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1133
1372
  function PlayerSkipCue({
1134
1373
  direction,
1135
1374
  cueId,
@@ -1138,14 +1377,14 @@ function PlayerSkipCue({
1138
1377
  if (!direction) return null;
1139
1378
  const isForward = direction === "forward";
1140
1379
  const label = isForward ? `+${seconds}` : `-${seconds}`;
1141
- return /* @__PURE__ */ jsx11(
1380
+ return /* @__PURE__ */ jsx10(
1142
1381
  "div",
1143
1382
  {
1144
1383
  className: `nsg-player-skip-cue ${isForward ? "nsg-player-skip-cue--forward" : "nsg-player-skip-cue--backward"}`,
1145
1384
  "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 })
1385
+ children: /* @__PURE__ */ jsxs8("div", { className: "nsg-player-skip-cue-badge", children: [
1386
+ /* @__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" }) }) }),
1387
+ /* @__PURE__ */ jsx10("span", { style: { fontSize: "1.125rem", fontWeight: 600 }, children: label })
1149
1388
  ] })
1150
1389
  },
1151
1390
  cueId
@@ -1153,29 +1392,89 @@ function PlayerSkipCue({
1153
1392
  }
1154
1393
 
1155
1394
  // src/components/PlayerChrome.tsx
1156
- import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1395
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
1157
1396
  function PlayerChrome({
1158
1397
  player,
1159
1398
  config,
1160
1399
  containerRef,
1161
1400
  videoSlot,
1162
1401
  className,
1163
- getSeekPreview
1402
+ getSeekPreview,
1403
+ mediaMode,
1404
+ audioAvailable,
1405
+ onMediaModeChange,
1406
+ sidecarCaptions,
1407
+ selectedSidecar,
1408
+ onSidecarChange,
1409
+ captionStatus
1164
1410
  }) {
1165
- const rootRef = useRef4(null);
1166
- const seekBarRef = useRef4(null);
1167
- const skipCueTimerRef = useRef4(null);
1168
- const [skipCue, setSkipCue] = useState5(null);
1411
+ const rootRef = useRef5(null);
1412
+ const seekBarRef = useRef5(null);
1413
+ const skipCueTimerRef = useRef5(null);
1414
+ const [skipCue, setSkipCue] = useState6(null);
1169
1415
  const controls = usePlayerControls({
1170
1416
  player,
1171
1417
  config,
1172
1418
  containerRef
1173
1419
  });
1420
+ const TOOLBAR_IDLE_MS = 5e3;
1421
+ const TOOLBAR_LEAVE_MS = 1200;
1422
+ const [toolbarVisible, setToolbarVisible] = useState6(true);
1423
+ const toolbarVisibleRef = useRef5(true);
1424
+ const controlsPinnedRef = useRef5(false);
1425
+ const idleTimerRef = useRef5(null);
1426
+ const clearToolbarIdle = useCallback3(() => {
1427
+ if (idleTimerRef.current) {
1428
+ window.clearTimeout(idleTimerRef.current);
1429
+ idleTimerRef.current = null;
1430
+ }
1431
+ }, []);
1432
+ const scheduleToolbarHide = useCallback3(
1433
+ (delayMs = TOOLBAR_IDLE_MS) => {
1434
+ clearToolbarIdle();
1435
+ idleTimerRef.current = window.setTimeout(() => {
1436
+ if (controlsPinnedRef.current) return;
1437
+ toolbarVisibleRef.current = false;
1438
+ setToolbarVisible(false);
1439
+ }, delayMs);
1440
+ },
1441
+ [clearToolbarIdle]
1442
+ );
1443
+ const revealToolbar = useCallback3(() => {
1444
+ if (!toolbarVisibleRef.current) {
1445
+ toolbarVisibleRef.current = true;
1446
+ setToolbarVisible(true);
1447
+ }
1448
+ if (!controlsPinnedRef.current) scheduleToolbarHide(TOOLBAR_IDLE_MS);
1449
+ }, [scheduleToolbarHide]);
1450
+ useEffect6(() => {
1451
+ if (!controls.showControls) {
1452
+ clearToolbarIdle();
1453
+ toolbarVisibleRef.current = false;
1454
+ setToolbarVisible(false);
1455
+ return;
1456
+ }
1457
+ revealToolbar();
1458
+ return clearToolbarIdle;
1459
+ }, [controls.showControls, revealToolbar, clearToolbarIdle]);
1460
+ const pinToolbar = useCallback3(() => {
1461
+ controlsPinnedRef.current = true;
1462
+ clearToolbarIdle();
1463
+ if (!toolbarVisibleRef.current) {
1464
+ toolbarVisibleRef.current = true;
1465
+ setToolbarVisible(true);
1466
+ }
1467
+ }, [clearToolbarIdle]);
1468
+ const releaseToolbar = useCallback3(() => {
1469
+ controlsPinnedRef.current = false;
1470
+ scheduleToolbarHide(TOOLBAR_IDLE_MS);
1471
+ }, [scheduleToolbarHide]);
1174
1472
  const overlay = resolvePlayerOverlay({
1175
1473
  showControls: controls.showControls,
1176
1474
  isPlaying: controls.isPlaying,
1177
1475
  muted: controls.muted,
1178
- volume: controls.volume
1476
+ volume: controls.volume,
1477
+ mediaMode
1179
1478
  });
1180
1479
  const flashSkipCue = useCallback3(
1181
1480
  (direction) => {
@@ -1202,21 +1501,23 @@ function PlayerChrome({
1202
1501
  flashSkipCue
1203
1502
  ]
1204
1503
  );
1205
- useEffect5(() => {
1504
+ useEffect6(() => {
1206
1505
  return () => {
1207
1506
  if (skipCueTimerRef.current) window.clearTimeout(skipCueTimerRef.current);
1208
1507
  };
1209
1508
  }, []);
1210
- useEffect5(() => {
1509
+ useEffect6(() => {
1211
1510
  const root = rootRef.current;
1212
- if (!root || !controls.showControls || !config.controls.keyboardShortcuts) {
1511
+ if (!root || !controls.showControls) {
1213
1512
  return;
1214
1513
  }
1215
1514
  const onKeyDown = (event) => {
1515
+ revealToolbar();
1216
1516
  const target = event.target;
1217
1517
  if (target && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable)) {
1218
1518
  return;
1219
1519
  }
1520
+ if (!config.controls.keyboardShortcuts) return;
1220
1521
  switch (event.key) {
1221
1522
  case " ":
1222
1523
  case "k":
@@ -1273,17 +1574,44 @@ function PlayerChrome({
1273
1574
  root.tabIndex = 0;
1274
1575
  root.addEventListener("keydown", onKeyDown);
1275
1576
  return () => root.removeEventListener("keydown", onKeyDown);
1276
- }, [controls, config, skip]);
1277
- return /* @__PURE__ */ jsxs10(
1577
+ }, [controls, config, skip, revealToolbar]);
1578
+ const showEdge = canShowEdgeProgress({
1579
+ showControls: controls.showControls,
1580
+ toolbarVisible,
1581
+ currentTime: controls.currentTime,
1582
+ duration: controls.duration,
1583
+ bufferedEnd: controls.bufferedEnd,
1584
+ isLive: controls.isLive
1585
+ });
1586
+ const edgePct = edgeProgressPercent({
1587
+ currentTime: controls.currentTime,
1588
+ duration: controls.duration,
1589
+ bufferedEnd: controls.bufferedEnd,
1590
+ isLive: controls.isLive,
1591
+ atLiveEdge: controls.atLiveEdge
1592
+ });
1593
+ return /* @__PURE__ */ jsxs9(
1278
1594
  "div",
1279
1595
  {
1280
1596
  ref: rootRef,
1281
- className: ["nsg-player-root", className].filter(Boolean).join(" "),
1597
+ className: [
1598
+ "nsg-player-root",
1599
+ toolbarVisible ? "nsg-player-root--toolbar-visible" : "nsg-player-root--toolbar-hidden",
1600
+ className
1601
+ ].filter(Boolean).join(" "),
1602
+ "data-toolbar-visible": toolbarVisible ? "true" : "false",
1282
1603
  role: "region",
1283
1604
  "aria-label": "Video player",
1605
+ onPointerEnter: controls.showControls ? revealToolbar : void 0,
1606
+ onPointerMove: controls.showControls ? revealToolbar : void 0,
1607
+ onPointerDown: controls.showControls ? revealToolbar : void 0,
1608
+ onPointerLeave: controls.showControls ? () => {
1609
+ if (controlsPinnedRef.current) return;
1610
+ scheduleToolbarHide(TOOLBAR_LEAVE_MS);
1611
+ } : void 0,
1284
1612
  onClick: controls.showControls ? controls.togglePlay : void 0,
1285
1613
  children: [
1286
- /* @__PURE__ */ jsx12(
1614
+ /* @__PURE__ */ jsx11(
1287
1615
  "div",
1288
1616
  {
1289
1617
  className: "nsg-player-video-wrap",
@@ -1291,16 +1619,17 @@ function PlayerChrome({
1291
1619
  children: videoSlot
1292
1620
  }
1293
1621
  ),
1294
- /* @__PURE__ */ jsx12(
1622
+ /* @__PURE__ */ jsx11(
1295
1623
  PlayerCenterOverlay,
1296
1624
  {
1297
1625
  kind: overlay,
1298
1626
  playIconPreset: config.theme.playIconPreset,
1299
1627
  onPlay: controls.togglePlay,
1300
- onEnableAudio: controls.enableAudio
1628
+ onEnableAudio: controls.enableAudio,
1629
+ onReturnToVideo: () => onMediaModeChange?.("video")
1301
1630
  }
1302
1631
  ),
1303
- /* @__PURE__ */ jsx12(
1632
+ /* @__PURE__ */ jsx11(
1304
1633
  PlayerSkipCue,
1305
1634
  {
1306
1635
  direction: skipCue?.direction ?? null,
@@ -1309,43 +1638,87 @@ function PlayerChrome({
1309
1638
  },
1310
1639
  skipCue?.id ?? "idle"
1311
1640
  ),
1312
- controls.showControls ? /* @__PURE__ */ jsx12(
1313
- PlayerControlBar,
1641
+ controls.showControls ? /* @__PURE__ */ jsx11(
1642
+ "div",
1314
1643
  {
1315
- config,
1316
- isPlaying: controls.isPlaying,
1317
- currentTime: controls.currentTime,
1318
- duration: controls.duration,
1319
- bufferedEnd: controls.bufferedEnd,
1320
- volume: controls.volume,
1321
- muted: controls.muted,
1322
- playbackRate: controls.playbackRate,
1323
- isFullscreen: controls.isFullscreen,
1324
- zoom: controls.zoom,
1325
- qualities: controls.qualities,
1326
- qualitySelection: controls.qualitySelection,
1327
- activeLevel: controls.activeLevel,
1328
- textTracks: controls.textTracks,
1329
- selectedTextTrack: controls.selectedTextTrack,
1330
- audioTracks: controls.audioTracks,
1331
- selectedAudioTrack: controls.selectedAudioTrack,
1332
- onTogglePlay: controls.togglePlay,
1333
- onSeek: controls.seekTo,
1334
- onSkip: skip,
1335
- isLive: controls.isLive,
1336
- atLiveEdge: controls.atLiveEdge,
1337
- onGoToLive: controls.goToLive,
1338
- onVolumeChange: controls.setVolume,
1339
- onToggleMute: controls.toggleMute,
1340
- onPlaybackRateChange: controls.setPlaybackRate,
1341
- onQualityChange: controls.setQuality,
1342
- onTextTrackChange: controls.setTextTrack,
1343
- onAudioTrackChange: controls.setAudioTrack,
1344
- onToggleFullscreen: () => void controls.toggleFullscreen(),
1345
- onZoomIn: controls.zoomIn,
1346
- onZoomOut: controls.zoomOut,
1347
- seekBarRef,
1348
- getSeekPreview
1644
+ className: [
1645
+ "nsg-player-toolbar-slot",
1646
+ toolbarVisible ? "nsg-player-toolbar-slot--visible" : "nsg-player-toolbar-slot--hidden"
1647
+ ].join(" "),
1648
+ "aria-hidden": !toolbarVisible,
1649
+ children: /* @__PURE__ */ jsx11(
1650
+ PlayerControlBar,
1651
+ {
1652
+ config,
1653
+ isPlaying: controls.isPlaying,
1654
+ currentTime: controls.currentTime,
1655
+ duration: controls.duration,
1656
+ bufferedEnd: controls.bufferedEnd,
1657
+ volume: controls.volume,
1658
+ muted: controls.muted,
1659
+ playbackRate: controls.playbackRate,
1660
+ isFullscreen: controls.isFullscreen,
1661
+ zoom: controls.zoom,
1662
+ qualities: controls.qualities,
1663
+ qualitySelection: controls.qualitySelection,
1664
+ activeLevel: controls.activeLevel,
1665
+ textTracks: controls.textTracks,
1666
+ selectedTextTrack: controls.selectedTextTrack,
1667
+ audioTracks: controls.audioTracks,
1668
+ selectedAudioTrack: controls.selectedAudioTrack,
1669
+ onTogglePlay: controls.togglePlay,
1670
+ onSeek: controls.seekTo,
1671
+ onSkip: skip,
1672
+ isLive: controls.isLive,
1673
+ atLiveEdge: controls.atLiveEdge,
1674
+ onGoToLive: controls.goToLive,
1675
+ onVolumeChange: controls.setVolume,
1676
+ onToggleMute: controls.toggleMute,
1677
+ onPlaybackRateChange: controls.setPlaybackRate,
1678
+ onQualityChange: controls.setQuality,
1679
+ onTextTrackChange: controls.setTextTrack,
1680
+ onAudioTrackChange: controls.setAudioTrack,
1681
+ onToggleFullscreen: () => void controls.toggleFullscreen(),
1682
+ onZoomChange: controls.setZoom,
1683
+ seekBarRef,
1684
+ mediaMode,
1685
+ audioAvailable,
1686
+ onMediaModeChange,
1687
+ sidecarCaptions,
1688
+ selectedSidecar,
1689
+ onSidecarChange,
1690
+ captionStatus,
1691
+ getSeekPreview,
1692
+ onPointerEnter: pinToolbar,
1693
+ onPointerLeave: releaseToolbar,
1694
+ onFocusCapture: pinToolbar,
1695
+ onBlurCapture: (event) => {
1696
+ const next = event.relatedTarget;
1697
+ if (next instanceof Node && event.currentTarget.contains(next)) {
1698
+ return;
1699
+ }
1700
+ releaseToolbar();
1701
+ }
1702
+ }
1703
+ )
1704
+ }
1705
+ ) : null,
1706
+ showEdge ? /* @__PURE__ */ jsx11(
1707
+ "div",
1708
+ {
1709
+ className: "nsg-player-edge-progress",
1710
+ "aria-hidden": true,
1711
+ onPointerDown: (event) => {
1712
+ event.stopPropagation();
1713
+ revealToolbar();
1714
+ },
1715
+ children: /* @__PURE__ */ jsx11(
1716
+ "div",
1717
+ {
1718
+ className: "nsg-player-edge-progress__played",
1719
+ style: { width: `${edgePct}%` }
1720
+ }
1721
+ )
1349
1722
  }
1350
1723
  ) : null
1351
1724
  ]
@@ -1354,7 +1727,7 @@ function PlayerChrome({
1354
1727
  }
1355
1728
 
1356
1729
  // src/hooks/usePlaybackWatermark.ts
1357
- import { useEffect as useEffect6, useRef as useRef5, useState as useState6 } from "react";
1730
+ import { useEffect as useEffect7, useRef as useRef6, useState as useState7 } from "react";
1358
1731
 
1359
1732
  // src/utils/watermarkSchedule.ts
1360
1733
  var WATERMARK_TOP_MIN_PCT = 8;
@@ -1404,11 +1777,11 @@ function usePlaybackWatermark({
1404
1777
  intervalMaxMs,
1405
1778
  reducedMotion = false
1406
1779
  }) {
1407
- const [state, setState] = useState6(HIDDEN);
1408
- const showTimerRef = useRef5(null);
1409
- const hideTimerRef = useRef5(null);
1410
- const generationRef = useRef5(0);
1411
- useEffect6(() => {
1780
+ const [state, setState] = useState7(HIDDEN);
1781
+ const showTimerRef = useRef6(null);
1782
+ const hideTimerRef = useRef6(null);
1783
+ const generationRef = useRef6(0);
1784
+ useEffect7(() => {
1412
1785
  const clearTimers = () => {
1413
1786
  if (showTimerRef.current !== null) {
1414
1787
  window.clearTimeout(showTimerRef.current);
@@ -1459,12 +1832,82 @@ function usePlaybackWatermark({
1459
1832
  return state;
1460
1833
  }
1461
1834
 
1835
+ // src/hooks/useRestoreSubtitleSelection.ts
1836
+ import {
1837
+ restoreSubtitleSelection
1838
+ } from "@codenkay/video-nsgplayer-core";
1839
+ import { useEffect as useEffect8 } from "react";
1840
+ function useRestoreSubtitleSelection({
1841
+ player,
1842
+ videoRef,
1843
+ language
1844
+ }) {
1845
+ useEffect8(() => {
1846
+ if (language === void 0) return;
1847
+ const video = videoRef.current;
1848
+ const apply = () => {
1849
+ const el = videoRef.current;
1850
+ if (el) restoreSubtitleSelection(el, language);
1851
+ };
1852
+ apply();
1853
+ const offs = [];
1854
+ if (player) {
1855
+ let previous = player.getState();
1856
+ offs.push(
1857
+ player.on("ready", apply),
1858
+ player.on("statechange", ({ state }) => {
1859
+ if (previous === "renewing" && state !== "renewing") apply();
1860
+ previous = state;
1861
+ })
1862
+ );
1863
+ }
1864
+ video?.addEventListener("loadedmetadata", apply);
1865
+ return () => {
1866
+ for (const off of offs) off();
1867
+ video?.removeEventListener("loadedmetadata", apply);
1868
+ };
1869
+ }, [player, videoRef, language]);
1870
+ }
1871
+
1872
+ // src/utils/playerError.ts
1873
+ import { PLATFORM_IN_USE, PLAYBACK_NOT_READY } from "@codenkay/video-nsgplayer-core";
1874
+ var PREPARING_MESSAGE = "Live video is preparing. Please retry shortly.";
1875
+ var GENERIC_ERROR_MESSAGE = "Unable to play this video.";
1876
+ var PLATFORM_LABELS = {
1877
+ android: "Android",
1878
+ ios: "iOS",
1879
+ web: "Web"
1880
+ };
1881
+ function describePlayerError(error) {
1882
+ if (!error) return null;
1883
+ const message = error.message?.trim();
1884
+ if (error.code === PLAYBACK_NOT_READY) {
1885
+ return { kind: "preparing", code: error.code, message: message || PREPARING_MESSAGE };
1886
+ }
1887
+ if (error.code === PLATFORM_IN_USE) {
1888
+ const label = error.activePlatform ? PLATFORM_LABELS[error.activePlatform] : void 0;
1889
+ return {
1890
+ kind: "platform-in-use",
1891
+ code: error.code,
1892
+ message: message || (label ? `You are already watching video on ${label}.` : "You are already watching video on another device.")
1893
+ };
1894
+ }
1895
+ return {
1896
+ kind: "error",
1897
+ code: error.code,
1898
+ message: message || GENERIC_ERROR_MESSAGE
1899
+ };
1900
+ }
1901
+
1462
1902
  // src/NsgVideoPlayerWithControls.tsx
1463
- import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
1903
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1464
1904
  var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2(props, ref) {
1465
- const containerRef = useRef6(null);
1466
- const onWatchTimeRef = useRef6(props.onWatchTime);
1905
+ const containerRef = useRef7(null);
1906
+ const onWatchTimeRef = useRef7(props.onWatchTime);
1467
1907
  onWatchTimeRef.current = props.onWatchTime;
1908
+ const pendingSwitchRef = useRef7(null);
1909
+ const switchGenerationRef = useRef7(0);
1910
+ const videoIdRef = useRef7(props.videoId);
1468
1911
  const resolvedConfig = useMemo2(
1469
1912
  () => mergePlayerConfig({
1470
1913
  ...props.config,
@@ -1489,7 +1932,59 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
1489
1932
  onAuthError: props.onAuthError
1490
1933
  });
1491
1934
  useImperativeHandle(ref, () => player, [player]);
1492
- useEffect7(() => {
1935
+ const requestMediaMode = (mode) => {
1936
+ if (mode === (props.mediaMode ?? "video")) return;
1937
+ const volume = player?.getVolume() ?? 1;
1938
+ const audible = volume > 0 ? volume : 1;
1939
+ const video = videoRef.current;
1940
+ if (video) {
1941
+ video.muted = false;
1942
+ video.volume = audible;
1943
+ }
1944
+ const playbackState = player?.getState();
1945
+ pendingSwitchRef.current = {
1946
+ time: player?.getCurrentTime() ?? 0,
1947
+ rate: player?.getPlaybackRate() ?? 1,
1948
+ volume: audible,
1949
+ playing: playbackState === "playing" || playbackState === "buffering"
1950
+ };
1951
+ props.onMediaModeChange?.(mode);
1952
+ };
1953
+ useEffect9(() => {
1954
+ if (videoIdRef.current !== props.videoId) {
1955
+ videoIdRef.current = props.videoId;
1956
+ pendingSwitchRef.current = null;
1957
+ return;
1958
+ }
1959
+ const pending = pendingSwitchRef.current;
1960
+ if (!pending || !player) return;
1961
+ pendingSwitchRef.current = null;
1962
+ const generation = ++switchGenerationRef.current;
1963
+ player.updateConfig({
1964
+ player: {
1965
+ startPosition: pending.time > 0.25 ? pending.time : 0,
1966
+ startMuted: false,
1967
+ volume: pending.volume,
1968
+ autoplay: pending.playing
1969
+ }
1970
+ });
1971
+ void player.reload().then(() => {
1972
+ if (generation !== switchGenerationRef.current) return;
1973
+ try {
1974
+ if (!player.isLive()) {
1975
+ player.setPlaybackRate(pending.rate);
1976
+ if (pending.time > 0.25 && Math.abs(player.getCurrentTime() - pending.time) > 1.5) {
1977
+ player.seek(pending.time);
1978
+ }
1979
+ }
1980
+ player.unmute();
1981
+ if (player.getVolume() <= 0) player.setVolume(pending.volume);
1982
+ if (pending.playing) void player.play();
1983
+ } catch {
1984
+ }
1985
+ });
1986
+ }, [player, props.mediaMode, props.videoId]);
1987
+ useEffect9(() => {
1493
1988
  if (!player) return;
1494
1989
  const report = () => {
1495
1990
  const t = player.getCurrentTime();
@@ -1506,10 +2001,17 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
1506
2001
  window.removeEventListener("beforeunload", onBeforeUnload);
1507
2002
  };
1508
2003
  }, [player]);
2004
+ useRestoreSubtitleSelection({
2005
+ player,
2006
+ videoRef,
2007
+ language: props.selectedSidecar
2008
+ });
2009
+ const errorDisplay = describePlayerError(error ?? props.leaseError);
2010
+ const watermarkLabel = props.watermarkText?.trim() || resolvedConfig.watermark.text?.trim() || null;
1509
2011
  const watermarkActive = state === "playing" || state === "paused" || state === "buffering";
1510
2012
  const watermark = usePlaybackWatermark({
1511
2013
  enabled: resolvedConfig.watermark.enabled,
1512
- label: resolvedConfig.watermark.text?.trim() || null,
2014
+ label: watermarkLabel,
1513
2015
  active: watermarkActive,
1514
2016
  durationMs: resolvedConfig.watermark.durationMs,
1515
2017
  intervalMaxMs: resolvedConfig.watermark.intervalMaxMs,
@@ -1517,7 +2019,7 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
1517
2019
  });
1518
2020
  const cssVars = themeToCssVars(resolvedConfig.theme);
1519
2021
  const showBootstrap = state === "loading" || state === "idle";
1520
- return /* @__PURE__ */ jsxs11(
2022
+ return /* @__PURE__ */ jsxs10(
1521
2023
  "div",
1522
2024
  {
1523
2025
  ref: containerRef,
@@ -1534,25 +2036,39 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
1534
2036
  ...props.style
1535
2037
  },
1536
2038
  children: [
1537
- /* @__PURE__ */ jsx13(
2039
+ /* @__PURE__ */ jsx12(
1538
2040
  PlayerChrome,
1539
2041
  {
1540
2042
  player,
1541
2043
  config: resolvedConfig,
1542
2044
  containerRef,
1543
2045
  getSeekPreview: props.getSeekPreview,
1544
- videoSlot: /* @__PURE__ */ jsx13(
2046
+ mediaMode: props.mediaMode,
2047
+ audioAvailable: props.audioAvailable,
2048
+ onMediaModeChange: requestMediaMode,
2049
+ sidecarCaptions: props.sidecarCaptions,
2050
+ selectedSidecar: props.selectedSidecar,
2051
+ onSidecarChange: props.onSidecarChange,
2052
+ captionStatus: props.captionStatus,
2053
+ videoSlot: /* @__PURE__ */ jsx12(
1545
2054
  "video",
1546
2055
  {
1547
2056
  ref: videoRef,
1548
2057
  playsInline: true,
1549
2058
  preload: "metadata",
1550
- style: { width: "100%", height: "100%", display: "block" }
2059
+ poster: props.mediaMode === "audio" ? props.poster : void 0,
2060
+ style: {
2061
+ width: "100%",
2062
+ height: "100%",
2063
+ display: "block",
2064
+ objectFit: "contain",
2065
+ background: "#000"
2066
+ }
1551
2067
  }
1552
2068
  )
1553
2069
  }
1554
2070
  ),
1555
- watermark.visible ? /* @__PURE__ */ jsx13(
2071
+ watermark.visible ? /* @__PURE__ */ jsx12(
1556
2072
  "div",
1557
2073
  {
1558
2074
  className: "nsg-player-watermark",
@@ -1561,19 +2077,107 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
1561
2077
  top: `${watermark.topPct}%`,
1562
2078
  left: `${watermark.leftPct}%`
1563
2079
  },
1564
- children: resolvedConfig.watermark.text
2080
+ children: watermarkLabel
2081
+ }
2082
+ ) : null,
2083
+ errorDisplay?.kind === "preparing" ? /* @__PURE__ */ jsx12(
2084
+ "p",
2085
+ {
2086
+ className: "nsg-player-status nsg-player-status--preparing",
2087
+ role: "status",
2088
+ "data-error-code": errorDisplay.code,
2089
+ children: errorDisplay.message
2090
+ }
2091
+ ) : errorDisplay ? /* @__PURE__ */ jsx12(
2092
+ "p",
2093
+ {
2094
+ className: "nsg-player-error",
2095
+ role: "alert",
2096
+ "data-error-code": errorDisplay.code,
2097
+ children: errorDisplay.message
1565
2098
  }
1566
2099
  ) : 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
2100
+ showBootstrap && !errorDisplay ? /* @__PURE__ */ jsx12("p", { className: "nsg-player-status", children: "Loading video\u2026" }) : null
1569
2101
  ]
1570
2102
  }
1571
2103
  );
1572
2104
  });
2105
+
2106
+ // src/components/QualitySelector.tsx
2107
+ import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
2108
+ function QualitySelector({
2109
+ qualities,
2110
+ selection,
2111
+ activeLevel,
2112
+ onSelect
2113
+ }) {
2114
+ if (qualities.length <= 1) return null;
2115
+ const sorted = [...qualities].sort(
2116
+ (a, b) => b.height - a.height || b.bitrate - a.bitrate
2117
+ );
2118
+ const activeLabel = activeLevel >= 0 ? qualities.find((q) => q.index === activeLevel)?.label : void 0;
2119
+ const buttonLabel = selection === "auto" ? activeLabel ? `Auto (${activeLabel})` : "Auto" : qualities.find((q) => q.index === selection)?.label ?? "Quality";
2120
+ return /* @__PURE__ */ jsxs11(PlayerMenu, { label: "Quality", buttonLabel, menuKind: "quality", children: [
2121
+ /* @__PURE__ */ jsxs11(
2122
+ PlayerMenuItem,
2123
+ {
2124
+ active: selection === "auto",
2125
+ menuKind: "quality",
2126
+ onSelect: () => onSelect("auto"),
2127
+ children: [
2128
+ "Auto",
2129
+ activeLabel ? ` (${activeLabel})` : ""
2130
+ ]
2131
+ }
2132
+ ),
2133
+ sorted.map((level) => /* @__PURE__ */ jsx13(
2134
+ PlayerMenuItem,
2135
+ {
2136
+ active: selection === level.index,
2137
+ menuKind: "quality",
2138
+ onSelect: () => onSelect(level.index),
2139
+ children: level.label
2140
+ },
2141
+ level.index
2142
+ ))
2143
+ ] });
2144
+ }
2145
+
2146
+ // src/components/TextTrackSelector.tsx
2147
+ import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
2148
+ function TextTrackSelector({
2149
+ tracks,
2150
+ selection,
2151
+ onSelect
2152
+ }) {
2153
+ if (tracks.length === 0) return null;
2154
+ const buttonLabel = selection === "off" ? "CC" : tracks.find((t) => t.index === selection)?.label ?? "CC";
2155
+ return /* @__PURE__ */ jsxs12(PlayerMenu, { label: "Captions", buttonLabel, children: [
2156
+ /* @__PURE__ */ jsx14(
2157
+ PlayerMenuItem,
2158
+ {
2159
+ active: selection === "off",
2160
+ onSelect: () => onSelect("off"),
2161
+ children: "Off"
2162
+ }
2163
+ ),
2164
+ tracks.map((track) => /* @__PURE__ */ jsx14(
2165
+ PlayerMenuItem,
2166
+ {
2167
+ active: selection === track.index,
2168
+ onSelect: () => onSelect(track.index),
2169
+ children: track.label
2170
+ },
2171
+ track.id
2172
+ ))
2173
+ ] });
2174
+ }
1573
2175
  export {
1574
2176
  AudioTrackSelector,
2177
+ GENERIC_ERROR_MESSAGE,
1575
2178
  LiveBadgeButton,
1576
2179
  NsgVideoPlayerWithControls,
2180
+ PREPARING_MESSAGE,
1577
2181
  PlayIconPreset,
1578
2182
  PlaybackSpeedSelector,
1579
2183
  PlayerCenterOverlay,
@@ -1585,8 +2189,10 @@ export {
1585
2189
  QUALITY_PREFERENCE_STORAGE_KEY,
1586
2190
  QualitySelector,
1587
2191
  SeekBar,
2192
+ SettingsMenu,
1588
2193
  TextTrackSelector,
1589
2194
  ZOOM_STEPS,
2195
+ describePlayerError,
1590
2196
  formatPlaybackTime,
1591
2197
  matchQualityPreference,
1592
2198
  nextZoom,
@@ -1600,6 +2206,7 @@ export {
1600
2206
  snapPlaybackRate,
1601
2207
  usePlaybackWatermark,
1602
2208
  usePlayerControls,
2209
+ useRestoreSubtitleSelection,
1603
2210
  writeQualityPreference
1604
2211
  };
1605
2212
  //# sourceMappingURL=index.js.map