@codenkay/video-nsgplayer-ui 5.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Align with core **5.4.0** and react **5.2.0**. Peer ranges: `@codenkay/video-nsgplayer-core@^5.4.0`, `@codenkay/video-nsgplayer-react@^5.2.0`.
8
+ - Idle toolbar hide: after 5s without pointer activity (or ~1.2s after the pointer leaves), the chrome fades out and a bottom-edge progress line remains for VOD and live. The toolbar stays mounted while hidden (CSS opacity/visibility).
9
+ - Responsive control chrome: wrapping rows, compact touch targets, hide volume slider / skip / time on narrow viewports and container queries, `max-width: 100%` on the root.
10
+ - Includes 5.2.0 lease error UI (`leaseError`, `describePlayerError`), `watermarkText`, and caption restore across renewals.
11
+
12
+ ## 5.2.1
13
+
14
+ ### Patch Changes
15
+
16
+ - Restore reliable idle toolbar hide: after 5s without pointer activity (or ~1.2s after the pointer leaves the player), the control chrome fades out and a bottom-edge progress line remains.
17
+ - Edge progress works for live as well as VOD (live uses the live-edge / buffered window when duration is not finite).
18
+ - Keep the toolbar mounted while hidden (CSS opacity/visibility) so idle show/hide does not remount controls.
19
+ - Responsive control chrome: wrapping rows, compact touch targets, hide volume slider / skip / time on narrow viewports and container queries, `max-width: 100%` on the root.
20
+
21
+ ## 5.2.0
22
+
23
+ ### Minor Changes
24
+
25
+ - Error UI now handles student lease errors. `PLAYBACK_NOT_READY` shows a polite "Live video is preparing" status instead of an alert. `PLATFORM_IN_USE` shows which platform holds the session ("You are already watching video on Android."). Other errors keep the generic alert. Pass a lease error with the new `leaseError` prop, or let the player's own `error` flow through. See `describePlayerError`.
26
+ - Keep the selected caption language across source renewals. `NsgVideoPlayerWithControls` calls core `restoreSubtitleSelection` for the `selectedSidecar` language after `ready`, after a renewal finishes, and on `loadedmetadata`. Only SDK-owned `<track>` elements (`data-sample-subtitle`, `data-appextech-subtitle`) are touched. Exported as `useRestoreSubtitleSelection` for custom chrome.
27
+ - Add a `watermarkText` prop for lease-driven watermark text. It overrides `config.watermark.text`, which stays the fallback.
28
+ - Peer range is now `@codenkay/video-nsgplayer-core@^5.3.0`.
29
+
3
30
  ## 5.1.0
4
31
 
5
32
  ### Minor Changes
package/README.md CHANGED
@@ -39,7 +39,7 @@ import "@codenkay/video-nsgplayer-ui/styles.css";
39
39
 
40
40
  Zoom is UI-only (CSS `scale`). Import `styles.css` once in the host app.
41
41
 
42
- UI **5.1.0** is not on npm yet. `onMediaModeChange` must switch the next signed URL before it returns. The player then resumes at the same time, rate, and audible volume. The toolbar hides after 5 seconds without pointer activity and leaves a progress line on the bottom edge. Settings lists quality, zoom, and subtitles when those tracks exist. Each row has an icon and an inset divider. Install core **5.2.0** for the buffer and token refresh. The React adapter can stay at 5.0.0.
42
+ UI **5.3.0** restores idle toolbar hide (5s inactivity or ~1.2s after pointer leave) with a bottom-edge progress line for VOD and live, plus responsive chrome for narrow viewports. `onMediaModeChange` must switch the next signed URL before it returns; the player resumes at the same time, rate, and audible volume. Settings lists quality, zoom, and subtitles when those tracks exist. Peer core **^5.4.0** and react **^5.2.0**.
43
43
 
44
44
  Published bundles include a `"use client";` banner for Next.js App Router. Pass `analytics`, use `ref` for `getDiagnostics()` / runtime API, and set `watermark.durationMs` / `intervalMaxMs` for intermittent anti-leak watermarks.
45
45
 
package/dist/index.cjs CHANGED
@@ -22,8 +22,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
22
22
  var index_exports = {};
23
23
  __export(index_exports, {
24
24
  AudioTrackSelector: () => AudioTrackSelector,
25
+ GENERIC_ERROR_MESSAGE: () => GENERIC_ERROR_MESSAGE,
25
26
  LiveBadgeButton: () => LiveBadgeButton,
26
27
  NsgVideoPlayerWithControls: () => NsgVideoPlayerWithControls,
28
+ PREPARING_MESSAGE: () => PREPARING_MESSAGE,
27
29
  PlayIconPreset: () => PlayIconPreset,
28
30
  PlaybackSpeedSelector: () => PlaybackSpeedSelector,
29
31
  PlayerCenterOverlay: () => PlayerCenterOverlay,
@@ -38,6 +40,7 @@ __export(index_exports, {
38
40
  SettingsMenu: () => SettingsMenu,
39
41
  TextTrackSelector: () => TextTrackSelector,
40
42
  ZOOM_STEPS: () => ZOOM_STEPS,
43
+ describePlayerError: () => describePlayerError,
41
44
  formatPlaybackTime: () => formatPlaybackTime,
42
45
  matchQualityPreference: () => matchQualityPreference,
43
46
  nextZoom: () => nextZoom,
@@ -51,13 +54,14 @@ __export(index_exports, {
51
54
  snapPlaybackRate: () => snapPlaybackRate,
52
55
  usePlaybackWatermark: () => usePlaybackWatermark,
53
56
  usePlayerControls: () => usePlayerControls,
57
+ useRestoreSubtitleSelection: () => useRestoreSubtitleSelection,
54
58
  writeQualityPreference: () => writeQualityPreference
55
59
  });
56
60
  module.exports = __toCommonJS(index_exports);
57
61
 
58
62
  // src/NsgVideoPlayerWithControls.tsx
59
- var import_react9 = require("react");
60
- var import_video_nsgplayer_core2 = require("@codenkay/video-nsgplayer-core");
63
+ var import_react10 = require("react");
64
+ var import_video_nsgplayer_core4 = require("@codenkay/video-nsgplayer-core");
61
65
  var import_video_nsgplayer_react = require("@codenkay/video-nsgplayer-react");
62
66
 
63
67
  // src/components/PlayerChrome.tsx
@@ -447,6 +451,33 @@ function usePlayerControls(options) {
447
451
  };
448
452
  }
449
453
 
454
+ // src/utils/edgeProgress.ts
455
+ function edgeProgressPercent(input) {
456
+ const { currentTime, duration, bufferedEnd, isLive, atLiveEdge } = input;
457
+ if (Number.isFinite(duration) && duration > 0) {
458
+ return Math.min(100, Math.max(0, currentTime / duration * 100));
459
+ }
460
+ if (isLive) {
461
+ if (atLiveEdge) {
462
+ return 100;
463
+ }
464
+ if (Number.isFinite(bufferedEnd) && bufferedEnd > 0) {
465
+ return Math.min(100, Math.max(0, currentTime / bufferedEnd * 100));
466
+ }
467
+ return 100;
468
+ }
469
+ return 0;
470
+ }
471
+ function canShowEdgeProgress(input) {
472
+ if (!input.showControls || input.toolbarVisible) {
473
+ return false;
474
+ }
475
+ if (input.isLive) {
476
+ return true;
477
+ }
478
+ return Number.isFinite(input.duration) && input.duration > 0;
479
+ }
480
+
450
481
  // src/components/PlayIconPreset.tsx
451
482
  var import_jsx_runtime = require("react/jsx-runtime");
452
483
  function PlayIconPreset({
@@ -1419,6 +1450,7 @@ function PlayerChrome({
1419
1450
  containerRef
1420
1451
  });
1421
1452
  const TOOLBAR_IDLE_MS = 5e3;
1453
+ const TOOLBAR_LEAVE_MS = 1200;
1422
1454
  const [toolbarVisible, setToolbarVisible] = (0, import_react7.useState)(true);
1423
1455
  const toolbarVisibleRef = (0, import_react7.useRef)(true);
1424
1456
  const controlsPinnedRef = (0, import_react7.useRef)(false);
@@ -1429,20 +1461,23 @@ function PlayerChrome({
1429
1461
  idleTimerRef.current = null;
1430
1462
  }
1431
1463
  }, []);
1432
- const scheduleToolbarHide = (0, import_react7.useCallback)(() => {
1433
- clearToolbarIdle();
1434
- idleTimerRef.current = window.setTimeout(() => {
1435
- if (controlsPinnedRef.current) return;
1436
- toolbarVisibleRef.current = false;
1437
- setToolbarVisible(false);
1438
- }, TOOLBAR_IDLE_MS);
1439
- }, [clearToolbarIdle]);
1464
+ const scheduleToolbarHide = (0, import_react7.useCallback)(
1465
+ (delayMs = TOOLBAR_IDLE_MS) => {
1466
+ clearToolbarIdle();
1467
+ idleTimerRef.current = window.setTimeout(() => {
1468
+ if (controlsPinnedRef.current) return;
1469
+ toolbarVisibleRef.current = false;
1470
+ setToolbarVisible(false);
1471
+ }, delayMs);
1472
+ },
1473
+ [clearToolbarIdle]
1474
+ );
1440
1475
  const revealToolbar = (0, import_react7.useCallback)(() => {
1441
1476
  if (!toolbarVisibleRef.current) {
1442
1477
  toolbarVisibleRef.current = true;
1443
1478
  setToolbarVisible(true);
1444
1479
  }
1445
- if (!controlsPinnedRef.current) scheduleToolbarHide();
1480
+ if (!controlsPinnedRef.current) scheduleToolbarHide(TOOLBAR_IDLE_MS);
1446
1481
  }, [scheduleToolbarHide]);
1447
1482
  (0, import_react7.useEffect)(() => {
1448
1483
  if (!controls.showControls) {
@@ -1464,7 +1499,7 @@ function PlayerChrome({
1464
1499
  }, [clearToolbarIdle]);
1465
1500
  const releaseToolbar = (0, import_react7.useCallback)(() => {
1466
1501
  controlsPinnedRef.current = false;
1467
- scheduleToolbarHide();
1502
+ scheduleToolbarHide(TOOLBAR_IDLE_MS);
1468
1503
  }, [scheduleToolbarHide]);
1469
1504
  const overlay = resolvePlayerOverlay({
1470
1505
  showControls: controls.showControls,
@@ -1572,16 +1607,40 @@ function PlayerChrome({
1572
1607
  root.addEventListener("keydown", onKeyDown);
1573
1608
  return () => root.removeEventListener("keydown", onKeyDown);
1574
1609
  }, [controls, config, skip, revealToolbar]);
1610
+ const showEdge = canShowEdgeProgress({
1611
+ showControls: controls.showControls,
1612
+ toolbarVisible,
1613
+ currentTime: controls.currentTime,
1614
+ duration: controls.duration,
1615
+ bufferedEnd: controls.bufferedEnd,
1616
+ isLive: controls.isLive
1617
+ });
1618
+ const edgePct = edgeProgressPercent({
1619
+ currentTime: controls.currentTime,
1620
+ duration: controls.duration,
1621
+ bufferedEnd: controls.bufferedEnd,
1622
+ isLive: controls.isLive,
1623
+ atLiveEdge: controls.atLiveEdge
1624
+ });
1575
1625
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1576
1626
  "div",
1577
1627
  {
1578
1628
  ref: rootRef,
1579
- className: ["nsg-player-root", className].filter(Boolean).join(" "),
1629
+ className: [
1630
+ "nsg-player-root",
1631
+ toolbarVisible ? "nsg-player-root--toolbar-visible" : "nsg-player-root--toolbar-hidden",
1632
+ className
1633
+ ].filter(Boolean).join(" "),
1634
+ "data-toolbar-visible": toolbarVisible ? "true" : "false",
1580
1635
  role: "region",
1581
1636
  "aria-label": "Video player",
1582
1637
  onPointerEnter: controls.showControls ? revealToolbar : void 0,
1583
1638
  onPointerMove: controls.showControls ? revealToolbar : void 0,
1584
1639
  onPointerDown: controls.showControls ? revealToolbar : void 0,
1640
+ onPointerLeave: controls.showControls ? () => {
1641
+ if (controlsPinnedRef.current) return;
1642
+ scheduleToolbarHide(TOOLBAR_LEAVE_MS);
1643
+ } : void 0,
1585
1644
  onClick: controls.showControls ? controls.togglePlay : void 0,
1586
1645
  children: [
1587
1646
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
@@ -1611,68 +1670,89 @@ function PlayerChrome({
1611
1670
  },
1612
1671
  skipCue?.id ?? "idle"
1613
1672
  ),
1614
- controls.showControls && toolbarVisible ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1615
- PlayerControlBar,
1673
+ controls.showControls ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1674
+ "div",
1616
1675
  {
1617
- config,
1618
- isPlaying: controls.isPlaying,
1619
- currentTime: controls.currentTime,
1620
- duration: controls.duration,
1621
- bufferedEnd: controls.bufferedEnd,
1622
- volume: controls.volume,
1623
- muted: controls.muted,
1624
- playbackRate: controls.playbackRate,
1625
- isFullscreen: controls.isFullscreen,
1626
- zoom: controls.zoom,
1627
- qualities: controls.qualities,
1628
- qualitySelection: controls.qualitySelection,
1629
- activeLevel: controls.activeLevel,
1630
- textTracks: controls.textTracks,
1631
- selectedTextTrack: controls.selectedTextTrack,
1632
- audioTracks: controls.audioTracks,
1633
- selectedAudioTrack: controls.selectedAudioTrack,
1634
- onTogglePlay: controls.togglePlay,
1635
- onSeek: controls.seekTo,
1636
- onSkip: skip,
1637
- isLive: controls.isLive,
1638
- atLiveEdge: controls.atLiveEdge,
1639
- onGoToLive: controls.goToLive,
1640
- onVolumeChange: controls.setVolume,
1641
- onToggleMute: controls.toggleMute,
1642
- onPlaybackRateChange: controls.setPlaybackRate,
1643
- onQualityChange: controls.setQuality,
1644
- onTextTrackChange: controls.setTextTrack,
1645
- onAudioTrackChange: controls.setAudioTrack,
1646
- onToggleFullscreen: () => void controls.toggleFullscreen(),
1647
- onZoomChange: controls.setZoom,
1648
- seekBarRef,
1649
- mediaMode,
1650
- audioAvailable,
1651
- onMediaModeChange,
1652
- sidecarCaptions,
1653
- selectedSidecar,
1654
- onSidecarChange,
1655
- captionStatus,
1656
- getSeekPreview,
1657
- onPointerEnter: pinToolbar,
1658
- onPointerLeave: releaseToolbar,
1659
- onFocusCapture: pinToolbar,
1660
- onBlurCapture: (event) => {
1661
- const next = event.relatedTarget;
1662
- if (next instanceof Node && event.currentTarget.contains(next)) return;
1663
- releaseToolbar();
1664
- }
1676
+ className: [
1677
+ "nsg-player-toolbar-slot",
1678
+ toolbarVisible ? "nsg-player-toolbar-slot--visible" : "nsg-player-toolbar-slot--hidden"
1679
+ ].join(" "),
1680
+ "aria-hidden": !toolbarVisible,
1681
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1682
+ PlayerControlBar,
1683
+ {
1684
+ config,
1685
+ isPlaying: controls.isPlaying,
1686
+ currentTime: controls.currentTime,
1687
+ duration: controls.duration,
1688
+ bufferedEnd: controls.bufferedEnd,
1689
+ volume: controls.volume,
1690
+ muted: controls.muted,
1691
+ playbackRate: controls.playbackRate,
1692
+ isFullscreen: controls.isFullscreen,
1693
+ zoom: controls.zoom,
1694
+ qualities: controls.qualities,
1695
+ qualitySelection: controls.qualitySelection,
1696
+ activeLevel: controls.activeLevel,
1697
+ textTracks: controls.textTracks,
1698
+ selectedTextTrack: controls.selectedTextTrack,
1699
+ audioTracks: controls.audioTracks,
1700
+ selectedAudioTrack: controls.selectedAudioTrack,
1701
+ onTogglePlay: controls.togglePlay,
1702
+ onSeek: controls.seekTo,
1703
+ onSkip: skip,
1704
+ isLive: controls.isLive,
1705
+ atLiveEdge: controls.atLiveEdge,
1706
+ onGoToLive: controls.goToLive,
1707
+ onVolumeChange: controls.setVolume,
1708
+ onToggleMute: controls.toggleMute,
1709
+ onPlaybackRateChange: controls.setPlaybackRate,
1710
+ onQualityChange: controls.setQuality,
1711
+ onTextTrackChange: controls.setTextTrack,
1712
+ onAudioTrackChange: controls.setAudioTrack,
1713
+ onToggleFullscreen: () => void controls.toggleFullscreen(),
1714
+ onZoomChange: controls.setZoom,
1715
+ seekBarRef,
1716
+ mediaMode,
1717
+ audioAvailable,
1718
+ onMediaModeChange,
1719
+ sidecarCaptions,
1720
+ selectedSidecar,
1721
+ onSidecarChange,
1722
+ captionStatus,
1723
+ getSeekPreview,
1724
+ onPointerEnter: pinToolbar,
1725
+ onPointerLeave: releaseToolbar,
1726
+ onFocusCapture: pinToolbar,
1727
+ onBlurCapture: (event) => {
1728
+ const next = event.relatedTarget;
1729
+ if (next instanceof Node && event.currentTarget.contains(next)) {
1730
+ return;
1731
+ }
1732
+ releaseToolbar();
1733
+ }
1734
+ }
1735
+ )
1665
1736
  }
1666
1737
  ) : null,
1667
- controls.showControls && !toolbarVisible && Number.isFinite(controls.duration) && controls.duration > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "nsg-player-edge-progress", "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1738
+ showEdge ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1668
1739
  "div",
1669
1740
  {
1670
- className: "nsg-player-edge-progress__played",
1671
- style: {
1672
- width: `${Math.min(100, controls.currentTime / controls.duration * 100)}%`
1673
- }
1741
+ className: "nsg-player-edge-progress",
1742
+ "aria-hidden": true,
1743
+ onPointerDown: (event) => {
1744
+ event.stopPropagation();
1745
+ revealToolbar();
1746
+ },
1747
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1748
+ "div",
1749
+ {
1750
+ className: "nsg-player-edge-progress__played",
1751
+ style: { width: `${edgePct}%` }
1752
+ }
1753
+ )
1674
1754
  }
1675
- ) }) : null
1755
+ ) : null
1676
1756
  ]
1677
1757
  }
1678
1758
  );
@@ -1784,17 +1864,82 @@ function usePlaybackWatermark({
1784
1864
  return state;
1785
1865
  }
1786
1866
 
1867
+ // src/hooks/useRestoreSubtitleSelection.ts
1868
+ var import_video_nsgplayer_core2 = require("@codenkay/video-nsgplayer-core");
1869
+ var import_react9 = require("react");
1870
+ function useRestoreSubtitleSelection({
1871
+ player,
1872
+ videoRef,
1873
+ language
1874
+ }) {
1875
+ (0, import_react9.useEffect)(() => {
1876
+ if (language === void 0) return;
1877
+ const video = videoRef.current;
1878
+ const apply = () => {
1879
+ const el = videoRef.current;
1880
+ if (el) (0, import_video_nsgplayer_core2.restoreSubtitleSelection)(el, language);
1881
+ };
1882
+ apply();
1883
+ const offs = [];
1884
+ if (player) {
1885
+ let previous = player.getState();
1886
+ offs.push(
1887
+ player.on("ready", apply),
1888
+ player.on("statechange", ({ state }) => {
1889
+ if (previous === "renewing" && state !== "renewing") apply();
1890
+ previous = state;
1891
+ })
1892
+ );
1893
+ }
1894
+ video?.addEventListener("loadedmetadata", apply);
1895
+ return () => {
1896
+ for (const off of offs) off();
1897
+ video?.removeEventListener("loadedmetadata", apply);
1898
+ };
1899
+ }, [player, videoRef, language]);
1900
+ }
1901
+
1902
+ // src/utils/playerError.ts
1903
+ var import_video_nsgplayer_core3 = require("@codenkay/video-nsgplayer-core");
1904
+ var PREPARING_MESSAGE = "Live video is preparing. Please retry shortly.";
1905
+ var GENERIC_ERROR_MESSAGE = "Unable to play this video.";
1906
+ var PLATFORM_LABELS = {
1907
+ android: "Android",
1908
+ ios: "iOS",
1909
+ web: "Web"
1910
+ };
1911
+ function describePlayerError(error) {
1912
+ if (!error) return null;
1913
+ const message = error.message?.trim();
1914
+ if (error.code === import_video_nsgplayer_core3.PLAYBACK_NOT_READY) {
1915
+ return { kind: "preparing", code: error.code, message: message || PREPARING_MESSAGE };
1916
+ }
1917
+ if (error.code === import_video_nsgplayer_core3.PLATFORM_IN_USE) {
1918
+ const label = error.activePlatform ? PLATFORM_LABELS[error.activePlatform] : void 0;
1919
+ return {
1920
+ kind: "platform-in-use",
1921
+ code: error.code,
1922
+ message: message || (label ? `You are already watching video on ${label}.` : "You are already watching video on another device.")
1923
+ };
1924
+ }
1925
+ return {
1926
+ kind: "error",
1927
+ code: error.code,
1928
+ message: message || GENERIC_ERROR_MESSAGE
1929
+ };
1930
+ }
1931
+
1787
1932
  // src/NsgVideoPlayerWithControls.tsx
1788
1933
  var import_jsx_runtime12 = require("react/jsx-runtime");
1789
- var NsgVideoPlayerWithControls = (0, import_react9.forwardRef)(function NsgVideoPlayerWithControls2(props, ref) {
1790
- const containerRef = (0, import_react9.useRef)(null);
1791
- const onWatchTimeRef = (0, import_react9.useRef)(props.onWatchTime);
1934
+ var NsgVideoPlayerWithControls = (0, import_react10.forwardRef)(function NsgVideoPlayerWithControls2(props, ref) {
1935
+ const containerRef = (0, import_react10.useRef)(null);
1936
+ const onWatchTimeRef = (0, import_react10.useRef)(props.onWatchTime);
1792
1937
  onWatchTimeRef.current = props.onWatchTime;
1793
- const pendingSwitchRef = (0, import_react9.useRef)(null);
1794
- const switchGenerationRef = (0, import_react9.useRef)(0);
1795
- const videoIdRef = (0, import_react9.useRef)(props.videoId);
1796
- const resolvedConfig = (0, import_react9.useMemo)(
1797
- () => (0, import_video_nsgplayer_core2.mergePlayerConfig)({
1938
+ const pendingSwitchRef = (0, import_react10.useRef)(null);
1939
+ const switchGenerationRef = (0, import_react10.useRef)(0);
1940
+ const videoIdRef = (0, import_react10.useRef)(props.videoId);
1941
+ const resolvedConfig = (0, import_react10.useMemo)(
1942
+ () => (0, import_video_nsgplayer_core4.mergePlayerConfig)({
1798
1943
  ...props.config,
1799
1944
  controls: {
1800
1945
  enabled: true,
@@ -1816,7 +1961,7 @@ var NsgVideoPlayerWithControls = (0, import_react9.forwardRef)(function NsgVideo
1816
1961
  onPause: props.onPause,
1817
1962
  onAuthError: props.onAuthError
1818
1963
  });
1819
- (0, import_react9.useImperativeHandle)(ref, () => player, [player]);
1964
+ (0, import_react10.useImperativeHandle)(ref, () => player, [player]);
1820
1965
  const requestMediaMode = (mode) => {
1821
1966
  if (mode === (props.mediaMode ?? "video")) return;
1822
1967
  const volume = player?.getVolume() ?? 1;
@@ -1835,7 +1980,7 @@ var NsgVideoPlayerWithControls = (0, import_react9.forwardRef)(function NsgVideo
1835
1980
  };
1836
1981
  props.onMediaModeChange?.(mode);
1837
1982
  };
1838
- (0, import_react9.useEffect)(() => {
1983
+ (0, import_react10.useEffect)(() => {
1839
1984
  if (videoIdRef.current !== props.videoId) {
1840
1985
  videoIdRef.current = props.videoId;
1841
1986
  pendingSwitchRef.current = null;
@@ -1869,7 +2014,7 @@ var NsgVideoPlayerWithControls = (0, import_react9.forwardRef)(function NsgVideo
1869
2014
  }
1870
2015
  });
1871
2016
  }, [player, props.mediaMode, props.videoId]);
1872
- (0, import_react9.useEffect)(() => {
2017
+ (0, import_react10.useEffect)(() => {
1873
2018
  if (!player) return;
1874
2019
  const report = () => {
1875
2020
  const t = player.getCurrentTime();
@@ -1886,16 +2031,23 @@ var NsgVideoPlayerWithControls = (0, import_react9.forwardRef)(function NsgVideo
1886
2031
  window.removeEventListener("beforeunload", onBeforeUnload);
1887
2032
  };
1888
2033
  }, [player]);
2034
+ useRestoreSubtitleSelection({
2035
+ player,
2036
+ videoRef,
2037
+ language: props.selectedSidecar
2038
+ });
2039
+ const errorDisplay = describePlayerError(error ?? props.leaseError);
2040
+ const watermarkLabel = props.watermarkText?.trim() || resolvedConfig.watermark.text?.trim() || null;
1889
2041
  const watermarkActive = state === "playing" || state === "paused" || state === "buffering";
1890
2042
  const watermark = usePlaybackWatermark({
1891
2043
  enabled: resolvedConfig.watermark.enabled,
1892
- label: resolvedConfig.watermark.text?.trim() || null,
2044
+ label: watermarkLabel,
1893
2045
  active: watermarkActive,
1894
2046
  durationMs: resolvedConfig.watermark.durationMs,
1895
2047
  intervalMaxMs: resolvedConfig.watermark.intervalMaxMs,
1896
2048
  reducedMotion: resolvedConfig.accessibility.reducedMotion
1897
2049
  });
1898
- const cssVars = (0, import_video_nsgplayer_core2.themeToCssVars)(resolvedConfig.theme);
2050
+ const cssVars = (0, import_video_nsgplayer_core4.themeToCssVars)(resolvedConfig.theme);
1899
2051
  const showBootstrap = state === "loading" || state === "idle";
1900
2052
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1901
2053
  "div",
@@ -1955,11 +2107,27 @@ var NsgVideoPlayerWithControls = (0, import_react9.forwardRef)(function NsgVideo
1955
2107
  top: `${watermark.topPct}%`,
1956
2108
  left: `${watermark.leftPct}%`
1957
2109
  },
1958
- children: resolvedConfig.watermark.text
2110
+ children: watermarkLabel
2111
+ }
2112
+ ) : null,
2113
+ errorDisplay?.kind === "preparing" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2114
+ "p",
2115
+ {
2116
+ className: "nsg-player-status nsg-player-status--preparing",
2117
+ role: "status",
2118
+ "data-error-code": errorDisplay.code,
2119
+ children: errorDisplay.message
2120
+ }
2121
+ ) : errorDisplay ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2122
+ "p",
2123
+ {
2124
+ className: "nsg-player-error",
2125
+ role: "alert",
2126
+ "data-error-code": errorDisplay.code,
2127
+ children: errorDisplay.message
1959
2128
  }
1960
2129
  ) : null,
1961
- error ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "nsg-player-error", role: "alert", children: error.message || "Unable to play this video." }) : null,
1962
- showBootstrap && !error ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "nsg-player-status", children: "Loading video\u2026" }) : null
2130
+ showBootstrap && !errorDisplay ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "nsg-player-status", children: "Loading video\u2026" }) : null
1963
2131
  ]
1964
2132
  }
1965
2133
  );
@@ -2037,8 +2205,10 @@ function TextTrackSelector({
2037
2205
  // Annotate the CommonJS export names for ESM import in node:
2038
2206
  0 && (module.exports = {
2039
2207
  AudioTrackSelector,
2208
+ GENERIC_ERROR_MESSAGE,
2040
2209
  LiveBadgeButton,
2041
2210
  NsgVideoPlayerWithControls,
2211
+ PREPARING_MESSAGE,
2042
2212
  PlayIconPreset,
2043
2213
  PlaybackSpeedSelector,
2044
2214
  PlayerCenterOverlay,
@@ -2053,6 +2223,7 @@ function TextTrackSelector({
2053
2223
  SettingsMenu,
2054
2224
  TextTrackSelector,
2055
2225
  ZOOM_STEPS,
2226
+ describePlayerError,
2056
2227
  formatPlaybackTime,
2057
2228
  matchQualityPreference,
2058
2229
  nextZoom,
@@ -2066,6 +2237,7 @@ function TextTrackSelector({
2066
2237
  snapPlaybackRate,
2067
2238
  usePlaybackWatermark,
2068
2239
  usePlayerControls,
2240
+ useRestoreSubtitleSelection,
2069
2241
  writeQualityPreference
2070
2242
  });
2071
2243
  //# sourceMappingURL=index.cjs.map