@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 +27 -0
- package/README.md +1 -1
- package/dist/index.cjs +257 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +244 -74
- package/dist/index.js.map +1 -1
- package/dist/player-ui.css +97 -3
- package/package.json +3 -3
- package/styles.css +97 -3
package/dist/index.d.cts
CHANGED
|
@@ -40,6 +40,28 @@ declare function SettingsMenu({ showQuality, qualities, qualitySelection, active
|
|
|
40
40
|
captionStatus?: string | null;
|
|
41
41
|
}): react.JSX.Element | null;
|
|
42
42
|
|
|
43
|
+
/** Minimal error shape accepted by the player error UI. */
|
|
44
|
+
type PlayerErrorLike = {
|
|
45
|
+
code?: string;
|
|
46
|
+
message?: string;
|
|
47
|
+
/** `StudentLeaseError.activePlatform` for `PLATFORM_IN_USE`. */
|
|
48
|
+
activePlatform?: string;
|
|
49
|
+
};
|
|
50
|
+
type PlayerErrorDisplay = {
|
|
51
|
+
/** `preparing` is informational; the others are blocking errors. */
|
|
52
|
+
kind: "preparing" | "platform-in-use" | "error";
|
|
53
|
+
code?: string;
|
|
54
|
+
message: string;
|
|
55
|
+
};
|
|
56
|
+
declare const PREPARING_MESSAGE = "Live video is preparing. Please retry shortly.";
|
|
57
|
+
declare const GENERIC_ERROR_MESSAGE = "Unable to play this video.";
|
|
58
|
+
/**
|
|
59
|
+
* Map a player or student-lease error to what the UI should show.
|
|
60
|
+
* `PLAYBACK_NOT_READY` is a transient "preparing" notice; `PLATFORM_IN_USE`
|
|
61
|
+
* names the other platform when known.
|
|
62
|
+
*/
|
|
63
|
+
declare function describePlayerError(error: PlayerErrorLike | null | undefined): PlayerErrorDisplay | null;
|
|
64
|
+
|
|
43
65
|
type NsgVideoPlayerWithControlsProps = {
|
|
44
66
|
videoId: string;
|
|
45
67
|
auth?: AuthConfig;
|
|
@@ -72,6 +94,17 @@ type NsgVideoPlayerWithControlsProps = {
|
|
|
72
94
|
selectedSidecar?: string | null;
|
|
73
95
|
onSidecarChange?: (language: string | null) => void;
|
|
74
96
|
captionStatus?: string | null;
|
|
97
|
+
/**
|
|
98
|
+
* Lease-driven watermark text (for example `useStudentLease().watermarkText`).
|
|
99
|
+
* Overrides `config.watermark.text`; the static text is the fallback.
|
|
100
|
+
*/
|
|
101
|
+
watermarkText?: string | null;
|
|
102
|
+
/**
|
|
103
|
+
* Error from outside the player, such as a `StudentLeaseError`
|
|
104
|
+
* (`PLATFORM_IN_USE`, `PLAYBACK_NOT_READY`). Shown when the player itself
|
|
105
|
+
* has no error.
|
|
106
|
+
*/
|
|
107
|
+
leaseError?: PlayerErrorLike | null;
|
|
75
108
|
};
|
|
76
109
|
/**
|
|
77
110
|
* Full player with control chrome (seek, quality, speed, live, zoom, keyboard).
|
|
@@ -326,4 +359,18 @@ declare function usePlaybackWatermark({ enabled, label, active, durationMs, inte
|
|
|
326
359
|
reducedMotion?: boolean;
|
|
327
360
|
}): PlaybackWatermarkState;
|
|
328
361
|
|
|
329
|
-
|
|
362
|
+
/**
|
|
363
|
+
* Keep the selected sidecar caption language after the media source is
|
|
364
|
+
* renewed or reloaded. Only SDK-owned `<track>` elements are touched
|
|
365
|
+
* (`data-sample-subtitle` / `data-appextech-subtitle`).
|
|
366
|
+
*
|
|
367
|
+
* `language`: a BCP 47 tag to show, `null` to turn SDK tracks off, or
|
|
368
|
+
* `undefined` when the host does not manage sidecar captions (no-op).
|
|
369
|
+
*/
|
|
370
|
+
declare function useRestoreSubtitleSelection({ player, videoRef, language, }: {
|
|
371
|
+
player: VideoPlayer | null;
|
|
372
|
+
videoRef: RefObject<HTMLVideoElement | null>;
|
|
373
|
+
language: string | null | undefined;
|
|
374
|
+
}): void;
|
|
375
|
+
|
|
376
|
+
export { AudioTrackSelector, GENERIC_ERROR_MESSAGE, LiveBadgeButton, NsgVideoPlayerWithControls, type NsgVideoPlayerWithControlsProps, PREPARING_MESSAGE, PlayIconPreset, PlaybackSpeedSelector, type PlaybackWatermarkState, PlayerCenterOverlay, PlayerChrome, type PlayerChromeProps, PlayerControlBar, type PlayerControlBarProps, type PlayerErrorDisplay, type PlayerErrorLike, PlayerMenu, PlayerMenuItem, type PlayerOverlayKind, PlayerSkipCue, type PlayerZoomLevel, QUALITY_PREFERENCE_STORAGE_KEY, QualitySelector, SeekBar, type SettingsCaption, SettingsMenu, type StoredQualityPreference, TextTrackSelector, type UsePlayerControlsOptions, type UsePlayerControlsResult, type WatermarkPosition, ZOOM_STEPS, describePlayerError, formatPlaybackTime, matchQualityPreference, nextZoom, preferenceFromSelection, randomFirstShowDelay, randomWatermarkDelay, randomWatermarkPosition, readQualityPreference, resolvePlayerOverlay, resolveVisiblePlaybackRates, snapPlaybackRate, usePlaybackWatermark, usePlayerControls, useRestoreSubtitleSelection, writeQualityPreference };
|
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,28 @@ declare function SettingsMenu({ showQuality, qualities, qualitySelection, active
|
|
|
40
40
|
captionStatus?: string | null;
|
|
41
41
|
}): react.JSX.Element | null;
|
|
42
42
|
|
|
43
|
+
/** Minimal error shape accepted by the player error UI. */
|
|
44
|
+
type PlayerErrorLike = {
|
|
45
|
+
code?: string;
|
|
46
|
+
message?: string;
|
|
47
|
+
/** `StudentLeaseError.activePlatform` for `PLATFORM_IN_USE`. */
|
|
48
|
+
activePlatform?: string;
|
|
49
|
+
};
|
|
50
|
+
type PlayerErrorDisplay = {
|
|
51
|
+
/** `preparing` is informational; the others are blocking errors. */
|
|
52
|
+
kind: "preparing" | "platform-in-use" | "error";
|
|
53
|
+
code?: string;
|
|
54
|
+
message: string;
|
|
55
|
+
};
|
|
56
|
+
declare const PREPARING_MESSAGE = "Live video is preparing. Please retry shortly.";
|
|
57
|
+
declare const GENERIC_ERROR_MESSAGE = "Unable to play this video.";
|
|
58
|
+
/**
|
|
59
|
+
* Map a player or student-lease error to what the UI should show.
|
|
60
|
+
* `PLAYBACK_NOT_READY` is a transient "preparing" notice; `PLATFORM_IN_USE`
|
|
61
|
+
* names the other platform when known.
|
|
62
|
+
*/
|
|
63
|
+
declare function describePlayerError(error: PlayerErrorLike | null | undefined): PlayerErrorDisplay | null;
|
|
64
|
+
|
|
43
65
|
type NsgVideoPlayerWithControlsProps = {
|
|
44
66
|
videoId: string;
|
|
45
67
|
auth?: AuthConfig;
|
|
@@ -72,6 +94,17 @@ type NsgVideoPlayerWithControlsProps = {
|
|
|
72
94
|
selectedSidecar?: string | null;
|
|
73
95
|
onSidecarChange?: (language: string | null) => void;
|
|
74
96
|
captionStatus?: string | null;
|
|
97
|
+
/**
|
|
98
|
+
* Lease-driven watermark text (for example `useStudentLease().watermarkText`).
|
|
99
|
+
* Overrides `config.watermark.text`; the static text is the fallback.
|
|
100
|
+
*/
|
|
101
|
+
watermarkText?: string | null;
|
|
102
|
+
/**
|
|
103
|
+
* Error from outside the player, such as a `StudentLeaseError`
|
|
104
|
+
* (`PLATFORM_IN_USE`, `PLAYBACK_NOT_READY`). Shown when the player itself
|
|
105
|
+
* has no error.
|
|
106
|
+
*/
|
|
107
|
+
leaseError?: PlayerErrorLike | null;
|
|
75
108
|
};
|
|
76
109
|
/**
|
|
77
110
|
* Full player with control chrome (seek, quality, speed, live, zoom, keyboard).
|
|
@@ -326,4 +359,18 @@ declare function usePlaybackWatermark({ enabled, label, active, durationMs, inte
|
|
|
326
359
|
reducedMotion?: boolean;
|
|
327
360
|
}): PlaybackWatermarkState;
|
|
328
361
|
|
|
329
|
-
|
|
362
|
+
/**
|
|
363
|
+
* Keep the selected sidecar caption language after the media source is
|
|
364
|
+
* renewed or reloaded. Only SDK-owned `<track>` elements are touched
|
|
365
|
+
* (`data-sample-subtitle` / `data-appextech-subtitle`).
|
|
366
|
+
*
|
|
367
|
+
* `language`: a BCP 47 tag to show, `null` to turn SDK tracks off, or
|
|
368
|
+
* `undefined` when the host does not manage sidecar captions (no-op).
|
|
369
|
+
*/
|
|
370
|
+
declare function useRestoreSubtitleSelection({ player, videoRef, language, }: {
|
|
371
|
+
player: VideoPlayer | null;
|
|
372
|
+
videoRef: RefObject<HTMLVideoElement | null>;
|
|
373
|
+
language: string | null | undefined;
|
|
374
|
+
}): void;
|
|
375
|
+
|
|
376
|
+
export { AudioTrackSelector, GENERIC_ERROR_MESSAGE, LiveBadgeButton, NsgVideoPlayerWithControls, type NsgVideoPlayerWithControlsProps, PREPARING_MESSAGE, PlayIconPreset, PlaybackSpeedSelector, type PlaybackWatermarkState, PlayerCenterOverlay, PlayerChrome, type PlayerChromeProps, PlayerControlBar, type PlayerControlBarProps, type PlayerErrorDisplay, type PlayerErrorLike, PlayerMenu, PlayerMenuItem, type PlayerOverlayKind, PlayerSkipCue, type PlayerZoomLevel, QUALITY_PREFERENCE_STORAGE_KEY, QualitySelector, SeekBar, type SettingsCaption, SettingsMenu, type StoredQualityPreference, TextTrackSelector, type UsePlayerControlsOptions, type UsePlayerControlsResult, type WatermarkPosition, ZOOM_STEPS, describePlayerError, formatPlaybackTime, matchQualityPreference, nextZoom, preferenceFromSelection, randomFirstShowDelay, randomWatermarkDelay, randomWatermarkPosition, readQualityPreference, resolvePlayerOverlay, resolveVisiblePlaybackRates, snapPlaybackRate, usePlaybackWatermark, usePlayerControls, useRestoreSubtitleSelection, writeQualityPreference };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/NsgVideoPlayerWithControls.tsx
|
|
4
4
|
import {
|
|
5
5
|
forwardRef,
|
|
6
|
-
useEffect as
|
|
6
|
+
useEffect as useEffect9,
|
|
7
7
|
useImperativeHandle,
|
|
8
8
|
useMemo as useMemo2,
|
|
9
9
|
useRef as useRef7
|
|
@@ -410,6 +410,33 @@ function usePlayerControls(options) {
|
|
|
410
410
|
};
|
|
411
411
|
}
|
|
412
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
|
+
|
|
413
440
|
// src/components/PlayIconPreset.tsx
|
|
414
441
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
415
442
|
function PlayIconPreset({
|
|
@@ -1391,6 +1418,7 @@ function PlayerChrome({
|
|
|
1391
1418
|
containerRef
|
|
1392
1419
|
});
|
|
1393
1420
|
const TOOLBAR_IDLE_MS = 5e3;
|
|
1421
|
+
const TOOLBAR_LEAVE_MS = 1200;
|
|
1394
1422
|
const [toolbarVisible, setToolbarVisible] = useState6(true);
|
|
1395
1423
|
const toolbarVisibleRef = useRef5(true);
|
|
1396
1424
|
const controlsPinnedRef = useRef5(false);
|
|
@@ -1401,20 +1429,23 @@ function PlayerChrome({
|
|
|
1401
1429
|
idleTimerRef.current = null;
|
|
1402
1430
|
}
|
|
1403
1431
|
}, []);
|
|
1404
|
-
const scheduleToolbarHide = useCallback3(
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
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
|
+
);
|
|
1412
1443
|
const revealToolbar = useCallback3(() => {
|
|
1413
1444
|
if (!toolbarVisibleRef.current) {
|
|
1414
1445
|
toolbarVisibleRef.current = true;
|
|
1415
1446
|
setToolbarVisible(true);
|
|
1416
1447
|
}
|
|
1417
|
-
if (!controlsPinnedRef.current) scheduleToolbarHide();
|
|
1448
|
+
if (!controlsPinnedRef.current) scheduleToolbarHide(TOOLBAR_IDLE_MS);
|
|
1418
1449
|
}, [scheduleToolbarHide]);
|
|
1419
1450
|
useEffect6(() => {
|
|
1420
1451
|
if (!controls.showControls) {
|
|
@@ -1436,7 +1467,7 @@ function PlayerChrome({
|
|
|
1436
1467
|
}, [clearToolbarIdle]);
|
|
1437
1468
|
const releaseToolbar = useCallback3(() => {
|
|
1438
1469
|
controlsPinnedRef.current = false;
|
|
1439
|
-
scheduleToolbarHide();
|
|
1470
|
+
scheduleToolbarHide(TOOLBAR_IDLE_MS);
|
|
1440
1471
|
}, [scheduleToolbarHide]);
|
|
1441
1472
|
const overlay = resolvePlayerOverlay({
|
|
1442
1473
|
showControls: controls.showControls,
|
|
@@ -1544,16 +1575,40 @@ function PlayerChrome({
|
|
|
1544
1575
|
root.addEventListener("keydown", onKeyDown);
|
|
1545
1576
|
return () => root.removeEventListener("keydown", onKeyDown);
|
|
1546
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
|
+
});
|
|
1547
1593
|
return /* @__PURE__ */ jsxs9(
|
|
1548
1594
|
"div",
|
|
1549
1595
|
{
|
|
1550
1596
|
ref: rootRef,
|
|
1551
|
-
className: [
|
|
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",
|
|
1552
1603
|
role: "region",
|
|
1553
1604
|
"aria-label": "Video player",
|
|
1554
1605
|
onPointerEnter: controls.showControls ? revealToolbar : void 0,
|
|
1555
1606
|
onPointerMove: controls.showControls ? revealToolbar : void 0,
|
|
1556
1607
|
onPointerDown: controls.showControls ? revealToolbar : void 0,
|
|
1608
|
+
onPointerLeave: controls.showControls ? () => {
|
|
1609
|
+
if (controlsPinnedRef.current) return;
|
|
1610
|
+
scheduleToolbarHide(TOOLBAR_LEAVE_MS);
|
|
1611
|
+
} : void 0,
|
|
1557
1612
|
onClick: controls.showControls ? controls.togglePlay : void 0,
|
|
1558
1613
|
children: [
|
|
1559
1614
|
/* @__PURE__ */ jsx11(
|
|
@@ -1583,68 +1638,89 @@ function PlayerChrome({
|
|
|
1583
1638
|
},
|
|
1584
1639
|
skipCue?.id ?? "idle"
|
|
1585
1640
|
),
|
|
1586
|
-
controls.showControls
|
|
1587
|
-
|
|
1641
|
+
controls.showControls ? /* @__PURE__ */ jsx11(
|
|
1642
|
+
"div",
|
|
1588
1643
|
{
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
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
|
+
)
|
|
1637
1704
|
}
|
|
1638
1705
|
) : null,
|
|
1639
|
-
|
|
1706
|
+
showEdge ? /* @__PURE__ */ jsx11(
|
|
1640
1707
|
"div",
|
|
1641
1708
|
{
|
|
1642
|
-
className: "nsg-player-edge-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
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
|
+
)
|
|
1646
1722
|
}
|
|
1647
|
-
)
|
|
1723
|
+
) : null
|
|
1648
1724
|
]
|
|
1649
1725
|
}
|
|
1650
1726
|
);
|
|
@@ -1756,6 +1832,73 @@ function usePlaybackWatermark({
|
|
|
1756
1832
|
return state;
|
|
1757
1833
|
}
|
|
1758
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
|
+
|
|
1759
1902
|
// src/NsgVideoPlayerWithControls.tsx
|
|
1760
1903
|
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1761
1904
|
var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2(props, ref) {
|
|
@@ -1807,7 +1950,7 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
|
|
|
1807
1950
|
};
|
|
1808
1951
|
props.onMediaModeChange?.(mode);
|
|
1809
1952
|
};
|
|
1810
|
-
|
|
1953
|
+
useEffect9(() => {
|
|
1811
1954
|
if (videoIdRef.current !== props.videoId) {
|
|
1812
1955
|
videoIdRef.current = props.videoId;
|
|
1813
1956
|
pendingSwitchRef.current = null;
|
|
@@ -1841,7 +1984,7 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
|
|
|
1841
1984
|
}
|
|
1842
1985
|
});
|
|
1843
1986
|
}, [player, props.mediaMode, props.videoId]);
|
|
1844
|
-
|
|
1987
|
+
useEffect9(() => {
|
|
1845
1988
|
if (!player) return;
|
|
1846
1989
|
const report = () => {
|
|
1847
1990
|
const t = player.getCurrentTime();
|
|
@@ -1858,10 +2001,17 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
|
|
|
1858
2001
|
window.removeEventListener("beforeunload", onBeforeUnload);
|
|
1859
2002
|
};
|
|
1860
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;
|
|
1861
2011
|
const watermarkActive = state === "playing" || state === "paused" || state === "buffering";
|
|
1862
2012
|
const watermark = usePlaybackWatermark({
|
|
1863
2013
|
enabled: resolvedConfig.watermark.enabled,
|
|
1864
|
-
label:
|
|
2014
|
+
label: watermarkLabel,
|
|
1865
2015
|
active: watermarkActive,
|
|
1866
2016
|
durationMs: resolvedConfig.watermark.durationMs,
|
|
1867
2017
|
intervalMaxMs: resolvedConfig.watermark.intervalMaxMs,
|
|
@@ -1927,11 +2077,27 @@ var NsgVideoPlayerWithControls = forwardRef(function NsgVideoPlayerWithControls2
|
|
|
1927
2077
|
top: `${watermark.topPct}%`,
|
|
1928
2078
|
left: `${watermark.leftPct}%`
|
|
1929
2079
|
},
|
|
1930
|
-
children:
|
|
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
|
|
1931
2098
|
}
|
|
1932
2099
|
) : null,
|
|
1933
|
-
|
|
1934
|
-
showBootstrap && !error ? /* @__PURE__ */ jsx12("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
|
|
1935
2101
|
]
|
|
1936
2102
|
}
|
|
1937
2103
|
);
|
|
@@ -2008,8 +2174,10 @@ function TextTrackSelector({
|
|
|
2008
2174
|
}
|
|
2009
2175
|
export {
|
|
2010
2176
|
AudioTrackSelector,
|
|
2177
|
+
GENERIC_ERROR_MESSAGE,
|
|
2011
2178
|
LiveBadgeButton,
|
|
2012
2179
|
NsgVideoPlayerWithControls,
|
|
2180
|
+
PREPARING_MESSAGE,
|
|
2013
2181
|
PlayIconPreset,
|
|
2014
2182
|
PlaybackSpeedSelector,
|
|
2015
2183
|
PlayerCenterOverlay,
|
|
@@ -2024,6 +2192,7 @@ export {
|
|
|
2024
2192
|
SettingsMenu,
|
|
2025
2193
|
TextTrackSelector,
|
|
2026
2194
|
ZOOM_STEPS,
|
|
2195
|
+
describePlayerError,
|
|
2027
2196
|
formatPlaybackTime,
|
|
2028
2197
|
matchQualityPreference,
|
|
2029
2198
|
nextZoom,
|
|
@@ -2037,6 +2206,7 @@ export {
|
|
|
2037
2206
|
snapPlaybackRate,
|
|
2038
2207
|
usePlaybackWatermark,
|
|
2039
2208
|
usePlayerControls,
|
|
2209
|
+
useRestoreSubtitleSelection,
|
|
2040
2210
|
writeQualityPreference
|
|
2041
2211
|
};
|
|
2042
2212
|
//# sourceMappingURL=index.js.map
|