@nikelroot/video-player 0.1.4 → 0.1.5
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/README.md +1 -0
- package/dist/index.cjs +30 -4
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +30 -4
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -87,6 +87,15 @@ var VideoPlayerControlStyles = import_styled_components.styled.div`
|
|
|
87
87
|
outline: none;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
.video-player-control-button:disabled {
|
|
91
|
+
opacity: 0.42;
|
|
92
|
+
cursor: not-allowed;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.video-player-control-button:disabled:hover {
|
|
96
|
+
background: rgba(255, 255, 255, 0.12);
|
|
97
|
+
}
|
|
98
|
+
|
|
90
99
|
.video-player-icon {
|
|
91
100
|
width: 17px;
|
|
92
101
|
height: 17px;
|
|
@@ -482,11 +491,23 @@ var Icon = ({ name }) => {
|
|
|
482
491
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { "aria-hidden": "true", className: "video-player-icon", focusable: "false", viewBox: "0 0 24 24", children: paths[name] });
|
|
483
492
|
};
|
|
484
493
|
var ControlButton = ({
|
|
494
|
+
disabled,
|
|
485
495
|
icon,
|
|
486
496
|
label,
|
|
487
497
|
onClick
|
|
488
498
|
}) => {
|
|
489
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
500
|
+
"button",
|
|
501
|
+
{
|
|
502
|
+
"aria-label": label,
|
|
503
|
+
className: "video-player-control-button",
|
|
504
|
+
disabled,
|
|
505
|
+
onClick: () => void onClick(),
|
|
506
|
+
title: label,
|
|
507
|
+
type: "button",
|
|
508
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: icon })
|
|
509
|
+
}
|
|
510
|
+
);
|
|
490
511
|
};
|
|
491
512
|
var stopControlClick = (e) => {
|
|
492
513
|
e.preventDefault();
|
|
@@ -496,6 +517,7 @@ var VideoPlayerControls = (props) => {
|
|
|
496
517
|
const {
|
|
497
518
|
variant,
|
|
498
519
|
fullScreenAction,
|
|
520
|
+
fullscreenAllowed,
|
|
499
521
|
showControl,
|
|
500
522
|
playAction,
|
|
501
523
|
pauseAction,
|
|
@@ -521,7 +543,7 @@ var VideoPlayerControls = (props) => {
|
|
|
521
543
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VideoPlayerControlStyles, { $isMobile: isMobile, onClick: stopControlClick, $showControl: showControl, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "video-player-control-row", children: [
|
|
522
544
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "full" }),
|
|
523
545
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlButton, { icon: muted ? "mute" : "sound", label: muted ? "Unmute" : "Mute", onClick: () => onMutedChange(!muted) }),
|
|
524
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlButton, { icon: "fullscreen", label: "Fullscreen", onClick: fullScreenAction })
|
|
546
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlButton, { disabled: !fullscreenAllowed, icon: "fullscreen", label: "Fullscreen", onClick: fullScreenAction })
|
|
525
547
|
] }) });
|
|
526
548
|
}
|
|
527
549
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VideoPlayerControlStyles, { $isMobile: isMobile, onClick: stopControlClick, $showControl: showControl, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "video-player-control-row", children: [
|
|
@@ -533,7 +555,7 @@ var VideoPlayerControls = (props) => {
|
|
|
533
555
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SeekSlider, { playAction, duration, currentTime, seekSetTime }),
|
|
534
556
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimeBlock, { duration, currentTime }),
|
|
535
557
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlButton, { icon: muted ? "mute" : "sound", label: muted ? "Unmute" : "Mute", onClick: () => onMutedChange(!muted) }),
|
|
536
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlButton, { icon: "fullscreen", label: "Fullscreen", onClick: fullScreenAction })
|
|
558
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlButton, { disabled: !fullscreenAllowed, icon: "fullscreen", label: "Fullscreen", onClick: fullScreenAction })
|
|
537
559
|
] }) });
|
|
538
560
|
};
|
|
539
561
|
|
|
@@ -751,6 +773,7 @@ var assignRef = (ref, value) => {
|
|
|
751
773
|
var VideoPlayerBase = (props, ref) => {
|
|
752
774
|
const {
|
|
753
775
|
controlsVariant = "none",
|
|
776
|
+
active,
|
|
754
777
|
autoPlay = false,
|
|
755
778
|
preload = "metadata",
|
|
756
779
|
loop = false,
|
|
@@ -824,6 +847,7 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
824
847
|
const muted = mutedProp != null ? mutedProp : mutedState;
|
|
825
848
|
const duration = durationProp != null ? durationProp : durationState;
|
|
826
849
|
const currentTime = currentTimeProp != null ? currentTimeProp : currentTimeState;
|
|
850
|
+
const fullscreenAllowed = active != null ? active : true;
|
|
827
851
|
const setTimeD = (0, import_react2.useRef)(
|
|
828
852
|
createThrottledNumberFn((value) => {
|
|
829
853
|
const v = videoRef.current;
|
|
@@ -1245,6 +1269,7 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1245
1269
|
else if (doc.msExitFullscreen) void doc.msExitFullscreen();
|
|
1246
1270
|
return;
|
|
1247
1271
|
}
|
|
1272
|
+
if (!fullscreenAllowed) return;
|
|
1248
1273
|
if (containerEl) {
|
|
1249
1274
|
if (containerEl.requestFullscreen) void containerEl.requestFullscreen();
|
|
1250
1275
|
else if (containerEl.webkitRequestFullscreen) void containerEl.webkitRequestFullscreen();
|
|
@@ -1256,7 +1281,7 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1256
1281
|
if (videoEl.requestFullscreen) void videoEl.requestFullscreen();
|
|
1257
1282
|
else if (videoEl.webkitEnterFullscreen) void videoEl.webkitEnterFullscreen();
|
|
1258
1283
|
}
|
|
1259
|
-
}, []);
|
|
1284
|
+
}, [fullscreenAllowed]);
|
|
1260
1285
|
const videoDbClickHandler = (0, import_react2.useCallback)(() => {
|
|
1261
1286
|
if (!handleClick) return;
|
|
1262
1287
|
fullScreenAction();
|
|
@@ -1439,6 +1464,7 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1439
1464
|
{
|
|
1440
1465
|
variant: controlsVariant,
|
|
1441
1466
|
fullScreenAction,
|
|
1467
|
+
fullscreenAllowed,
|
|
1442
1468
|
showControl,
|
|
1443
1469
|
playAction,
|
|
1444
1470
|
pauseAction,
|
package/dist/index.d.cts
CHANGED
|
@@ -37,6 +37,7 @@ interface VideoPlayerProps extends Omit<React.VideoHTMLAttributes<HTMLVideoEleme
|
|
|
37
37
|
sourceType?: 'auto' | 'hls' | 'native';
|
|
38
38
|
type?: string;
|
|
39
39
|
controlsVariant: ControlsVariant;
|
|
40
|
+
active?: boolean;
|
|
40
41
|
autoPlay?: boolean;
|
|
41
42
|
preload?: '' | 'none' | 'auto' | 'metadata';
|
|
42
43
|
loop?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ interface VideoPlayerProps extends Omit<React.VideoHTMLAttributes<HTMLVideoEleme
|
|
|
37
37
|
sourceType?: 'auto' | 'hls' | 'native';
|
|
38
38
|
type?: string;
|
|
39
39
|
controlsVariant: ControlsVariant;
|
|
40
|
+
active?: boolean;
|
|
40
41
|
autoPlay?: boolean;
|
|
41
42
|
preload?: '' | 'none' | 'auto' | 'metadata';
|
|
42
43
|
loop?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,15 @@ var VideoPlayerControlStyles = styled.div`
|
|
|
58
58
|
outline: none;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
.video-player-control-button:disabled {
|
|
62
|
+
opacity: 0.42;
|
|
63
|
+
cursor: not-allowed;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.video-player-control-button:disabled:hover {
|
|
67
|
+
background: rgba(255, 255, 255, 0.12);
|
|
68
|
+
}
|
|
69
|
+
|
|
61
70
|
.video-player-icon {
|
|
62
71
|
width: 17px;
|
|
63
72
|
height: 17px;
|
|
@@ -453,11 +462,23 @@ var Icon = ({ name }) => {
|
|
|
453
462
|
return /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", className: "video-player-icon", focusable: "false", viewBox: "0 0 24 24", children: paths[name] });
|
|
454
463
|
};
|
|
455
464
|
var ControlButton = ({
|
|
465
|
+
disabled,
|
|
456
466
|
icon,
|
|
457
467
|
label,
|
|
458
468
|
onClick
|
|
459
469
|
}) => {
|
|
460
|
-
return /* @__PURE__ */ jsx(
|
|
470
|
+
return /* @__PURE__ */ jsx(
|
|
471
|
+
"button",
|
|
472
|
+
{
|
|
473
|
+
"aria-label": label,
|
|
474
|
+
className: "video-player-control-button",
|
|
475
|
+
disabled,
|
|
476
|
+
onClick: () => void onClick(),
|
|
477
|
+
title: label,
|
|
478
|
+
type: "button",
|
|
479
|
+
children: /* @__PURE__ */ jsx(Icon, { name: icon })
|
|
480
|
+
}
|
|
481
|
+
);
|
|
461
482
|
};
|
|
462
483
|
var stopControlClick = (e) => {
|
|
463
484
|
e.preventDefault();
|
|
@@ -467,6 +488,7 @@ var VideoPlayerControls = (props) => {
|
|
|
467
488
|
const {
|
|
468
489
|
variant,
|
|
469
490
|
fullScreenAction,
|
|
491
|
+
fullscreenAllowed,
|
|
470
492
|
showControl,
|
|
471
493
|
playAction,
|
|
472
494
|
pauseAction,
|
|
@@ -492,7 +514,7 @@ var VideoPlayerControls = (props) => {
|
|
|
492
514
|
return /* @__PURE__ */ jsx(VideoPlayerControlStyles, { $isMobile: isMobile, onClick: stopControlClick, $showControl: showControl, children: /* @__PURE__ */ jsxs("div", { className: "video-player-control-row", children: [
|
|
493
515
|
/* @__PURE__ */ jsx("div", { className: "full" }),
|
|
494
516
|
/* @__PURE__ */ jsx(ControlButton, { icon: muted ? "mute" : "sound", label: muted ? "Unmute" : "Mute", onClick: () => onMutedChange(!muted) }),
|
|
495
|
-
/* @__PURE__ */ jsx(ControlButton, { icon: "fullscreen", label: "Fullscreen", onClick: fullScreenAction })
|
|
517
|
+
/* @__PURE__ */ jsx(ControlButton, { disabled: !fullscreenAllowed, icon: "fullscreen", label: "Fullscreen", onClick: fullScreenAction })
|
|
496
518
|
] }) });
|
|
497
519
|
}
|
|
498
520
|
return /* @__PURE__ */ jsx(VideoPlayerControlStyles, { $isMobile: isMobile, onClick: stopControlClick, $showControl: showControl, children: /* @__PURE__ */ jsxs("div", { className: "video-player-control-row", children: [
|
|
@@ -504,7 +526,7 @@ var VideoPlayerControls = (props) => {
|
|
|
504
526
|
/* @__PURE__ */ jsx(SeekSlider, { playAction, duration, currentTime, seekSetTime }),
|
|
505
527
|
/* @__PURE__ */ jsx(TimeBlock, { duration, currentTime }),
|
|
506
528
|
/* @__PURE__ */ jsx(ControlButton, { icon: muted ? "mute" : "sound", label: muted ? "Unmute" : "Mute", onClick: () => onMutedChange(!muted) }),
|
|
507
|
-
/* @__PURE__ */ jsx(ControlButton, { icon: "fullscreen", label: "Fullscreen", onClick: fullScreenAction })
|
|
529
|
+
/* @__PURE__ */ jsx(ControlButton, { disabled: !fullscreenAllowed, icon: "fullscreen", label: "Fullscreen", onClick: fullScreenAction })
|
|
508
530
|
] }) });
|
|
509
531
|
};
|
|
510
532
|
|
|
@@ -722,6 +744,7 @@ var assignRef = (ref, value) => {
|
|
|
722
744
|
var VideoPlayerBase = (props, ref) => {
|
|
723
745
|
const {
|
|
724
746
|
controlsVariant = "none",
|
|
747
|
+
active,
|
|
725
748
|
autoPlay = false,
|
|
726
749
|
preload = "metadata",
|
|
727
750
|
loop = false,
|
|
@@ -795,6 +818,7 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
795
818
|
const muted = mutedProp != null ? mutedProp : mutedState;
|
|
796
819
|
const duration = durationProp != null ? durationProp : durationState;
|
|
797
820
|
const currentTime = currentTimeProp != null ? currentTimeProp : currentTimeState;
|
|
821
|
+
const fullscreenAllowed = active != null ? active : true;
|
|
798
822
|
const setTimeD = useRef(
|
|
799
823
|
createThrottledNumberFn((value) => {
|
|
800
824
|
const v = videoRef.current;
|
|
@@ -1216,6 +1240,7 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1216
1240
|
else if (doc.msExitFullscreen) void doc.msExitFullscreen();
|
|
1217
1241
|
return;
|
|
1218
1242
|
}
|
|
1243
|
+
if (!fullscreenAllowed) return;
|
|
1219
1244
|
if (containerEl) {
|
|
1220
1245
|
if (containerEl.requestFullscreen) void containerEl.requestFullscreen();
|
|
1221
1246
|
else if (containerEl.webkitRequestFullscreen) void containerEl.webkitRequestFullscreen();
|
|
@@ -1227,7 +1252,7 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1227
1252
|
if (videoEl.requestFullscreen) void videoEl.requestFullscreen();
|
|
1228
1253
|
else if (videoEl.webkitEnterFullscreen) void videoEl.webkitEnterFullscreen();
|
|
1229
1254
|
}
|
|
1230
|
-
}, []);
|
|
1255
|
+
}, [fullscreenAllowed]);
|
|
1231
1256
|
const videoDbClickHandler = useCallback(() => {
|
|
1232
1257
|
if (!handleClick) return;
|
|
1233
1258
|
fullScreenAction();
|
|
@@ -1410,6 +1435,7 @@ var VideoPlayerBase = (props, ref) => {
|
|
|
1410
1435
|
{
|
|
1411
1436
|
variant: controlsVariant,
|
|
1412
1437
|
fullScreenAction,
|
|
1438
|
+
fullscreenAllowed,
|
|
1413
1439
|
showControl,
|
|
1414
1440
|
playAction,
|
|
1415
1441
|
pauseAction,
|