@guardvideo/player-sdk 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.esm.js +700 -58
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +699 -57
- package/dist/index.js.map +1 -1
- package/dist/react/GuardVideoPlayer.d.ts.map +1 -1
- package/dist/vanilla/core/types.d.ts.map +1 -1
- package/dist/vanilla/guardvideo-player.js +2 -2
- package/dist/vanilla/guardvideo-player.js.map +1 -1
- package/dist/vanilla/guardvideo-player.min.js +2 -2
- package/dist/vanilla/guardvideo-player.min.js.map +1 -1
- package/dist/vanilla/react/GuardVideoPlayer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Hls from 'hls.js';
|
|
2
|
-
import React, { forwardRef, useRef, useState, useEffect,
|
|
2
|
+
import React, { forwardRef, useRef, useState, useEffect, useCallback, useImperativeHandle } from 'react';
|
|
3
3
|
|
|
4
4
|
var PlayerState;
|
|
5
5
|
(function (PlayerState) {
|
|
@@ -64,7 +64,7 @@ class GuardVideoPlayer {
|
|
|
64
64
|
security: { ...DEFAULT_SECURITY, ...config.security },
|
|
65
65
|
viewerName: config.viewerName || '',
|
|
66
66
|
viewerEmail: config.viewerEmail || '',
|
|
67
|
-
forensicWatermark: config.forensicWatermark
|
|
67
|
+
forensicWatermark: config.forensicWatermark !== false,
|
|
68
68
|
onReady: config.onReady || (() => { }),
|
|
69
69
|
onError: config.onError || (() => { }),
|
|
70
70
|
onQualityChange: config.onQualityChange || (() => { }),
|
|
@@ -459,7 +459,7 @@ class GuardVideoPlayer {
|
|
|
459
459
|
maxViews: null,
|
|
460
460
|
...(this.config.viewerName ? { viewerName: this.config.viewerName } : {}),
|
|
461
461
|
...(this.config.viewerEmail ? { viewerEmail: this.config.viewerEmail } : {}),
|
|
462
|
-
|
|
462
|
+
forensicWatermark: this.config.forensicWatermark,
|
|
463
463
|
}),
|
|
464
464
|
});
|
|
465
465
|
if (!response.ok) {
|
|
@@ -657,12 +657,446 @@ class GuardVideoPlayer {
|
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
659
|
|
|
660
|
+
function formatTime(seconds) {
|
|
661
|
+
if (!isFinite(seconds) || isNaN(seconds))
|
|
662
|
+
return '0:00';
|
|
663
|
+
const h = Math.floor(seconds / 3600);
|
|
664
|
+
const m = Math.floor((seconds % 3600) / 60);
|
|
665
|
+
const s = Math.floor(seconds % 60);
|
|
666
|
+
const mm = String(m).padStart(h > 0 ? 2 : 1, '0');
|
|
667
|
+
const ss = String(s).padStart(2, '0');
|
|
668
|
+
return h > 0 ? `${h}:${mm}:${ss}` : `${mm}:${ss}`;
|
|
669
|
+
}
|
|
670
|
+
const PlayIcon = () => (React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor" },
|
|
671
|
+
React.createElement("polygon", { points: "5,3 19,12 5,21" })));
|
|
672
|
+
const PauseIcon = () => (React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor" },
|
|
673
|
+
React.createElement("rect", { x: "6", y: "4", width: "4", height: "16", rx: "1" }),
|
|
674
|
+
React.createElement("rect", { x: "14", y: "4", width: "4", height: "16", rx: "1" })));
|
|
675
|
+
const ReplayIcon = () => (React.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor" },
|
|
676
|
+
React.createElement("path", { d: "M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z" })));
|
|
677
|
+
const VolumeHighIcon = () => (React.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" },
|
|
678
|
+
React.createElement("path", { d: "M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z" })));
|
|
679
|
+
const VolumeMuteIcon = () => (React.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" },
|
|
680
|
+
React.createElement("path", { d: "M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z" })));
|
|
681
|
+
const FullscreenIcon = () => (React.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" },
|
|
682
|
+
React.createElement("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" })));
|
|
683
|
+
const ExitFullscreenIcon = () => (React.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" },
|
|
684
|
+
React.createElement("path", { d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" })));
|
|
685
|
+
const SettingsIcon = () => (React.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" },
|
|
686
|
+
React.createElement("path", { d: "M19.14,12.94c0.04-0.3,0.06-0.61,0.06-0.94c0-0.32-0.02-0.64-0.07-0.94l2.03-1.58c0.18-0.14,0.23-0.41,0.12-0.61 l-1.92-3.32c-0.12-0.22-0.37-0.29-0.59-0.22l-2.39,0.96c-0.5-0.38-1.03-0.7-1.62-0.94L14.4,2.81c-0.04-0.24-0.24-0.41-0.48-0.41 h-3.84c-0.24,0-0.43,0.17-0.47,0.41L9.25,5.35C8.66,5.59,8.12,5.92,7.63,6.29L5.24,5.33c-0.22-0.08-0.47,0-0.59,0.22L2.74,8.87 C2.62,9.08,2.66,9.34,2.86,9.48l2.03,1.58C4.84,11.36,4.8,11.69,4.8,12s0.02,0.64,0.07,0.94l-2.03,1.58 c-0.18,0.14-0.23,0.41-0.12,0.61l1.92,3.32c0.12,0.22,0.37,0.29,0.59,0.22l2.39-0.96c0.5,0.38,1.03,0.7,1.62,0.94l0.36,2.54 c0.05,0.24,0.24,0.41,0.48,0.41h3.84c0.24,0,0.44-0.17,0.47-0.41l0.36-2.54c0.59-0.24,1.13-0.56,1.62-0.94l2.39,0.96 c0.22,0.08,0.47,0,0.59-0.22l1.92-3.32c0.12-0.22,0.07-0.47-0.12-0.61L19.14,12.94z M12,15.6c-1.98,0-3.6-1.62-3.6-3.6 s1.62-3.6,3.6-3.6s3.6,1.62,3.6,3.6S13.98,15.6,12,15.6z" })));
|
|
687
|
+
const ShieldIcon = ({ color }) => (React.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: color, strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" },
|
|
688
|
+
React.createElement("path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" })));
|
|
689
|
+
let _stylesInjected = false;
|
|
690
|
+
function injectPlayerStyles(accentColor) {
|
|
691
|
+
if (_stylesInjected)
|
|
692
|
+
return;
|
|
693
|
+
_stylesInjected = true;
|
|
694
|
+
const css = `
|
|
695
|
+
/* ── GuardVideo Custom Player ─────────────────────────────── */
|
|
696
|
+
.gvp-root {
|
|
697
|
+
position: relative;
|
|
698
|
+
background: #000;
|
|
699
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
700
|
+
border-radius: 10px;
|
|
701
|
+
overflow: hidden;
|
|
702
|
+
-webkit-user-select: none;
|
|
703
|
+
user-select: none;
|
|
704
|
+
outline: none;
|
|
705
|
+
}
|
|
706
|
+
.gvp-root:focus-visible { box-shadow: 0 0 0 3px ${accentColor}66; }
|
|
707
|
+
|
|
708
|
+
.gvp-video {
|
|
709
|
+
display: block;
|
|
710
|
+
width: 100%;
|
|
711
|
+
height: 100%;
|
|
712
|
+
object-fit: contain;
|
|
713
|
+
border-radius: 10px;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/* ── Loading spinner ─────────────────────────────────────── */
|
|
717
|
+
.gvp-spinner {
|
|
718
|
+
position: absolute;
|
|
719
|
+
inset: 0;
|
|
720
|
+
display: flex;
|
|
721
|
+
align-items: center;
|
|
722
|
+
justify-content: center;
|
|
723
|
+
pointer-events: none;
|
|
724
|
+
background: rgba(0,0,0,0.55);
|
|
725
|
+
border-radius: 10px;
|
|
726
|
+
}
|
|
727
|
+
.gvp-spinner-ring {
|
|
728
|
+
width: 48px;
|
|
729
|
+
height: 48px;
|
|
730
|
+
border: 3px solid rgba(255,255,255,0.15);
|
|
731
|
+
border-top-color: ${accentColor};
|
|
732
|
+
border-radius: 50%;
|
|
733
|
+
animation: gvp-spin 0.8s linear infinite;
|
|
734
|
+
}
|
|
735
|
+
@keyframes gvp-spin { to { transform: rotate(360deg); } }
|
|
736
|
+
|
|
737
|
+
/* ── Big centre play button (initial state) ───────────────── */
|
|
738
|
+
.gvp-center-play {
|
|
739
|
+
position: absolute;
|
|
740
|
+
inset: 0;
|
|
741
|
+
display: flex;
|
|
742
|
+
align-items: center;
|
|
743
|
+
justify-content: center;
|
|
744
|
+
cursor: pointer;
|
|
745
|
+
background: rgba(0,0,0,0.3);
|
|
746
|
+
transition: background 0.2s;
|
|
747
|
+
border-radius: 10px;
|
|
748
|
+
}
|
|
749
|
+
.gvp-center-play:hover { background: rgba(0,0,0,0.45); }
|
|
750
|
+
.gvp-center-play-btn {
|
|
751
|
+
width: 72px;
|
|
752
|
+
height: 72px;
|
|
753
|
+
background: rgba(255,255,255,0.12);
|
|
754
|
+
backdrop-filter: blur(8px);
|
|
755
|
+
border-radius: 50%;
|
|
756
|
+
display: flex;
|
|
757
|
+
align-items: center;
|
|
758
|
+
justify-content: center;
|
|
759
|
+
border: 2px solid rgba(255,255,255,0.25);
|
|
760
|
+
transition: background 0.2s, transform 0.15s;
|
|
761
|
+
color: #fff;
|
|
762
|
+
}
|
|
763
|
+
.gvp-center-play:hover .gvp-center-play-btn {
|
|
764
|
+
background: ${accentColor}cc;
|
|
765
|
+
transform: scale(1.08);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/* ── Click-to-toggle overlay ─────────────────────────────── */
|
|
769
|
+
.gvp-click-area {
|
|
770
|
+
position: absolute;
|
|
771
|
+
inset: 0;
|
|
772
|
+
cursor: pointer;
|
|
773
|
+
z-index: 1;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/* ── Ripple effect on click ──────────────────────────────── */
|
|
777
|
+
.gvp-ripple {
|
|
778
|
+
position: absolute;
|
|
779
|
+
border-radius: 50%;
|
|
780
|
+
transform: scale(0);
|
|
781
|
+
background: rgba(255,255,255,0.25);
|
|
782
|
+
animation: gvp-ripple-anim 0.5s ease-out forwards;
|
|
783
|
+
pointer-events: none;
|
|
784
|
+
z-index: 2;
|
|
785
|
+
}
|
|
786
|
+
@keyframes gvp-ripple-anim { to { transform: scale(4); opacity: 0; } }
|
|
787
|
+
|
|
788
|
+
/* ── Controls bar ────────────────────────────────────────── */
|
|
789
|
+
.gvp-controls {
|
|
790
|
+
position: absolute;
|
|
791
|
+
bottom: 0;
|
|
792
|
+
left: 0;
|
|
793
|
+
right: 0;
|
|
794
|
+
z-index: 10;
|
|
795
|
+
background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
|
|
796
|
+
padding: 36px 14px 10px;
|
|
797
|
+
transition: opacity 0.3s, transform 0.3s;
|
|
798
|
+
border-radius: 0 0 10px 10px;
|
|
799
|
+
}
|
|
800
|
+
.gvp-controls-hidden {
|
|
801
|
+
opacity: 0;
|
|
802
|
+
transform: translateY(6px);
|
|
803
|
+
pointer-events: none;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/* ── Progress / seek bar ─────────────────────────────────── */
|
|
807
|
+
.gvp-seek-row {
|
|
808
|
+
display: flex;
|
|
809
|
+
align-items: center;
|
|
810
|
+
gap: 8px;
|
|
811
|
+
margin-bottom: 6px;
|
|
812
|
+
}
|
|
813
|
+
.gvp-seek-wrap {
|
|
814
|
+
flex: 1;
|
|
815
|
+
position: relative;
|
|
816
|
+
height: 4px;
|
|
817
|
+
cursor: pointer;
|
|
818
|
+
padding: 8px 0;
|
|
819
|
+
margin: -8px 0;
|
|
820
|
+
box-sizing: content-box;
|
|
821
|
+
}
|
|
822
|
+
.gvp-seek-track {
|
|
823
|
+
height: 4px;
|
|
824
|
+
background: rgba(255,255,255,0.2);
|
|
825
|
+
border-radius: 4px;
|
|
826
|
+
position: relative;
|
|
827
|
+
overflow: hidden;
|
|
828
|
+
transition: height 0.15s;
|
|
829
|
+
}
|
|
830
|
+
.gvp-seek-wrap:hover .gvp-seek-track { height: 6px; }
|
|
831
|
+
.gvp-seek-buffered {
|
|
832
|
+
position: absolute;
|
|
833
|
+
left: 0;
|
|
834
|
+
top: 0;
|
|
835
|
+
height: 100%;
|
|
836
|
+
background: rgba(255,255,255,0.35);
|
|
837
|
+
border-radius: 4px;
|
|
838
|
+
pointer-events: none;
|
|
839
|
+
}
|
|
840
|
+
.gvp-seek-progress {
|
|
841
|
+
position: absolute;
|
|
842
|
+
left: 0;
|
|
843
|
+
top: 0;
|
|
844
|
+
height: 100%;
|
|
845
|
+
background: ${accentColor};
|
|
846
|
+
border-radius: 4px;
|
|
847
|
+
pointer-events: none;
|
|
848
|
+
transition: width 0.1s linear;
|
|
849
|
+
}
|
|
850
|
+
.gvp-seek-thumb {
|
|
851
|
+
position: absolute;
|
|
852
|
+
top: 50%;
|
|
853
|
+
transform: translate(-50%, -50%);
|
|
854
|
+
width: 13px;
|
|
855
|
+
height: 13px;
|
|
856
|
+
background: #fff;
|
|
857
|
+
border-radius: 50%;
|
|
858
|
+
box-shadow: 0 1px 4px rgba(0,0,0,0.5);
|
|
859
|
+
pointer-events: none;
|
|
860
|
+
opacity: 0;
|
|
861
|
+
transition: opacity 0.15s;
|
|
862
|
+
}
|
|
863
|
+
.gvp-seek-wrap:hover .gvp-seek-thumb { opacity: 1; }
|
|
864
|
+
|
|
865
|
+
/* ── Time tooltip ─────────────────────────────────────────── */
|
|
866
|
+
.gvp-seek-tooltip {
|
|
867
|
+
position: absolute;
|
|
868
|
+
bottom: 24px;
|
|
869
|
+
transform: translateX(-50%);
|
|
870
|
+
background: rgba(0,0,0,0.8);
|
|
871
|
+
color: #fff;
|
|
872
|
+
font-size: 11px;
|
|
873
|
+
font-weight: 500;
|
|
874
|
+
padding: 3px 7px;
|
|
875
|
+
border-radius: 4px;
|
|
876
|
+
pointer-events: none;
|
|
877
|
+
white-space: nowrap;
|
|
878
|
+
opacity: 0;
|
|
879
|
+
transition: opacity 0.1s;
|
|
880
|
+
}
|
|
881
|
+
.gvp-seek-wrap:hover .gvp-seek-tooltip { opacity: 1; }
|
|
882
|
+
|
|
883
|
+
/* ── Bottom control row ───────────────────────────────────── */
|
|
884
|
+
.gvp-btn-row {
|
|
885
|
+
display: flex;
|
|
886
|
+
align-items: center;
|
|
887
|
+
gap: 4px;
|
|
888
|
+
}
|
|
889
|
+
.gvp-btn {
|
|
890
|
+
background: none;
|
|
891
|
+
border: none;
|
|
892
|
+
color: #fff;
|
|
893
|
+
cursor: pointer;
|
|
894
|
+
padding: 5px;
|
|
895
|
+
border-radius: 6px;
|
|
896
|
+
display: flex;
|
|
897
|
+
align-items: center;
|
|
898
|
+
justify-content: center;
|
|
899
|
+
transition: background 0.15s, color 0.15s;
|
|
900
|
+
flex-shrink: 0;
|
|
901
|
+
}
|
|
902
|
+
.gvp-btn:hover { background: rgba(255,255,255,0.12); color: ${accentColor}; }
|
|
903
|
+
.gvp-btn:active { background: rgba(255,255,255,0.2); }
|
|
904
|
+
|
|
905
|
+
/* ── Volume section ──────────────────────────────────────── */
|
|
906
|
+
.gvp-volume-wrap {
|
|
907
|
+
display: flex;
|
|
908
|
+
align-items: center;
|
|
909
|
+
gap: 5px;
|
|
910
|
+
}
|
|
911
|
+
.gvp-volume-slider {
|
|
912
|
+
-webkit-appearance: none;
|
|
913
|
+
width: 70px;
|
|
914
|
+
height: 4px;
|
|
915
|
+
background: rgba(255,255,255,0.25);
|
|
916
|
+
border-radius: 4px;
|
|
917
|
+
outline: none;
|
|
918
|
+
cursor: pointer;
|
|
919
|
+
accent-color: ${accentColor};
|
|
920
|
+
transition: width 0.2s;
|
|
921
|
+
}
|
|
922
|
+
.gvp-volume-slider::-webkit-slider-thumb {
|
|
923
|
+
-webkit-appearance: none;
|
|
924
|
+
width: 12px; height: 12px;
|
|
925
|
+
border-radius: 50%;
|
|
926
|
+
background: #fff;
|
|
927
|
+
cursor: pointer;
|
|
928
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
|
|
929
|
+
}
|
|
930
|
+
.gvp-volume-slider::-moz-range-thumb {
|
|
931
|
+
width: 12px; height: 12px;
|
|
932
|
+
border-radius: 50%;
|
|
933
|
+
background: #fff;
|
|
934
|
+
cursor: pointer;
|
|
935
|
+
border: none;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/* ── Time display ─────────────────────────────────────────── */
|
|
939
|
+
.gvp-time {
|
|
940
|
+
font-size: 12px;
|
|
941
|
+
color: rgba(255,255,255,0.85);
|
|
942
|
+
font-variant-numeric: tabular-nums;
|
|
943
|
+
white-space: nowrap;
|
|
944
|
+
letter-spacing: 0.02em;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
/* ── Spacer ──────────────────────────────────────────────── */
|
|
948
|
+
.gvp-spacer { flex: 1; }
|
|
949
|
+
|
|
950
|
+
/* ── Quality / Settings menu ──────────────────────────────── */
|
|
951
|
+
.gvp-menu-wrap {
|
|
952
|
+
position: relative;
|
|
953
|
+
}
|
|
954
|
+
.gvp-menu {
|
|
955
|
+
position: absolute;
|
|
956
|
+
bottom: calc(100% + 8px);
|
|
957
|
+
right: 0;
|
|
958
|
+
background: rgba(18,18,22,0.95);
|
|
959
|
+
backdrop-filter: blur(12px);
|
|
960
|
+
-webkit-backdrop-filter: blur(12px);
|
|
961
|
+
border: 1px solid rgba(255,255,255,0.08);
|
|
962
|
+
border-radius: 8px;
|
|
963
|
+
min-width: 140px;
|
|
964
|
+
overflow: hidden;
|
|
965
|
+
box-shadow: 0 8px 24px rgba(0,0,0,0.5);
|
|
966
|
+
animation: gvp-menu-in 0.1s ease-out;
|
|
967
|
+
z-index: 20;
|
|
968
|
+
}
|
|
969
|
+
@keyframes gvp-menu-in { from { opacity:0; transform: scale(0.95) translateY(4px); } to { opacity:1; transform: scale(1) translateY(0); } }
|
|
970
|
+
.gvp-menu-title {
|
|
971
|
+
font-size: 10px;
|
|
972
|
+
font-weight: 600;
|
|
973
|
+
text-transform: uppercase;
|
|
974
|
+
letter-spacing: 0.08em;
|
|
975
|
+
color: rgba(255,255,255,0.4);
|
|
976
|
+
padding: 8px 12px 4px;
|
|
977
|
+
}
|
|
978
|
+
.gvp-menu-item {
|
|
979
|
+
display: flex;
|
|
980
|
+
align-items: center;
|
|
981
|
+
justify-content: space-between;
|
|
982
|
+
padding: 7px 12px;
|
|
983
|
+
font-size: 13px;
|
|
984
|
+
color: rgba(255,255,255,0.85);
|
|
985
|
+
cursor: pointer;
|
|
986
|
+
transition: background 0.12s;
|
|
987
|
+
gap: 10px;
|
|
988
|
+
}
|
|
989
|
+
.gvp-menu-item:hover { background: rgba(255,255,255,0.07); }
|
|
990
|
+
.gvp-menu-item-active { color: ${accentColor}; font-weight: 600; }
|
|
991
|
+
.gvp-menu-check { font-size: 14px; color: ${accentColor}; }
|
|
992
|
+
.gvp-menu-sep { height: 1px; background: rgba(255,255,255,0.07); margin: 3px 0; }
|
|
993
|
+
|
|
994
|
+
/* ── Error overlay ────────────────────────────────────────── */
|
|
995
|
+
.gvp-error {
|
|
996
|
+
position: absolute;
|
|
997
|
+
inset: 0;
|
|
998
|
+
display: flex;
|
|
999
|
+
flex-direction: column;
|
|
1000
|
+
align-items: center;
|
|
1001
|
+
justify-content: center;
|
|
1002
|
+
background: rgba(0,0,0,0.8);
|
|
1003
|
+
color: #fff;
|
|
1004
|
+
gap: 10px;
|
|
1005
|
+
padding: 24px;
|
|
1006
|
+
border-radius: 10px;
|
|
1007
|
+
text-align: center;
|
|
1008
|
+
}
|
|
1009
|
+
.gvp-error-icon { font-size: 36px; }
|
|
1010
|
+
.gvp-error-code { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; color: #f87171; text-transform: uppercase; }
|
|
1011
|
+
.gvp-error-msg { font-size: 14px; color: rgba(255,255,255,0.7); max-width: 320px; line-height: 1.5; }
|
|
1012
|
+
|
|
1013
|
+
/* ── Secure badge ─────────────────────────────────────────── */
|
|
1014
|
+
.gvp-badge {
|
|
1015
|
+
position: absolute;
|
|
1016
|
+
top: 10px;
|
|
1017
|
+
right: 12px;
|
|
1018
|
+
display: flex;
|
|
1019
|
+
align-items: center;
|
|
1020
|
+
gap: 5px;
|
|
1021
|
+
background: rgba(0,0,0,0.55);
|
|
1022
|
+
backdrop-filter: blur(6px);
|
|
1023
|
+
border-radius: 20px;
|
|
1024
|
+
padding: 3px 9px 3px 7px;
|
|
1025
|
+
font-size: 10px;
|
|
1026
|
+
font-weight: 600;
|
|
1027
|
+
color: ${accentColor};
|
|
1028
|
+
pointer-events: none;
|
|
1029
|
+
z-index: 5;
|
|
1030
|
+
letter-spacing: 0.04em;
|
|
1031
|
+
transition: opacity 0.3s;
|
|
1032
|
+
}
|
|
1033
|
+
.gvp-badge-hidden { opacity: 0; }
|
|
1034
|
+
|
|
1035
|
+
/* ── Forensic watermark strip ─────────────────────────────── */
|
|
1036
|
+
.gvp-watermark {
|
|
1037
|
+
position: absolute;
|
|
1038
|
+
inset: 0;
|
|
1039
|
+
pointer-events: none;
|
|
1040
|
+
overflow: hidden;
|
|
1041
|
+
z-index: 6;
|
|
1042
|
+
}
|
|
1043
|
+
.gvp-watermark-text {
|
|
1044
|
+
position: absolute;
|
|
1045
|
+
white-space: nowrap;
|
|
1046
|
+
font-size: 13px;
|
|
1047
|
+
font-family: monospace;
|
|
1048
|
+
color: rgba(255,255,255,0.065);
|
|
1049
|
+
transform: rotate(-28deg);
|
|
1050
|
+
user-select: none;
|
|
1051
|
+
pointer-events: none;
|
|
1052
|
+
letter-spacing: 0.05em;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/* ── Playback rate menu ────────────────────────────────────── */
|
|
1056
|
+
.gvp-rate-label {
|
|
1057
|
+
font-size: 11px;
|
|
1058
|
+
font-weight: 700;
|
|
1059
|
+
color: rgba(255,255,255,0.7);
|
|
1060
|
+
min-width: 28px;
|
|
1061
|
+
text-align: center;
|
|
1062
|
+
cursor: pointer;
|
|
1063
|
+
padding: 5px 4px;
|
|
1064
|
+
border-radius: 4px;
|
|
1065
|
+
transition: background 0.12s;
|
|
1066
|
+
flex-shrink: 0;
|
|
1067
|
+
}
|
|
1068
|
+
.gvp-rate-label:hover { background: rgba(255,255,255,0.1); }
|
|
1069
|
+
`;
|
|
1070
|
+
const tag = document.createElement('style');
|
|
1071
|
+
tag.setAttribute('data-guardvideo', 'player-ui-styles');
|
|
1072
|
+
tag.textContent = css;
|
|
1073
|
+
document.head.appendChild(tag);
|
|
1074
|
+
}
|
|
660
1075
|
const GuardVideoPlayerComponent = forwardRef((props, ref) => {
|
|
661
|
-
const { videoId, width = '100%', height = 'auto', embedTokenEndpoint, apiBaseUrl, debug = false, autoplay = false,
|
|
1076
|
+
const { videoId, width = '100%', height = 'auto', embedTokenEndpoint, apiBaseUrl, debug = false, autoplay = false, className = '', style = {}, hlsConfig, branding, contextMenuItems, security, viewerName, viewerEmail, forensicWatermark = true, onReady, onError, onQualityChange, onStateChange, onTimeUpdate: onTimeUpdateProp, onEnded, } = props;
|
|
1077
|
+
const accentColor = branding?.accentColor ?? '#44c09b';
|
|
1078
|
+
const brandName = branding?.name ?? 'GuardVideo';
|
|
1079
|
+
const containerRef = useRef(null);
|
|
662
1080
|
const videoRef = useRef(null);
|
|
663
1081
|
const playerRef = useRef(null);
|
|
1082
|
+
const seekRef = useRef(null);
|
|
1083
|
+
const hideTimer = useRef(null);
|
|
1084
|
+
const [playerState, setPlayerState] = useState(PlayerState.IDLE);
|
|
1085
|
+
const [currentTime, setCurrentTime] = useState(0);
|
|
1086
|
+
const [duration, setDuration] = useState(0);
|
|
1087
|
+
const [buffered, setBuffered] = useState(0);
|
|
1088
|
+
const [volume, setVolume] = useState(1);
|
|
1089
|
+
const [muted, setMuted] = useState(false);
|
|
1090
|
+
const [showControls, setShowControls] = useState(true);
|
|
1091
|
+
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
1092
|
+
const [showMenu, setShowMenu] = useState(null);
|
|
1093
|
+
const [qualityLevels, setQualityLevels] = useState([]);
|
|
1094
|
+
const [currentQualityIdx, setCurrentQualityIdx] = useState(-1);
|
|
1095
|
+
const [playbackRate, setPlaybackRate] = useState(1);
|
|
1096
|
+
const [seekTooltip, setSeekTooltip] = useState(null);
|
|
664
1097
|
const [error, setError] = useState(null);
|
|
665
|
-
const [
|
|
1098
|
+
const [watermarkText, setWatermarkText] = useState(null);
|
|
1099
|
+
useEffect(() => { injectPlayerStyles(accentColor); }, [accentColor]);
|
|
666
1100
|
useEffect(() => {
|
|
667
1101
|
if (!videoRef.current || playerRef.current)
|
|
668
1102
|
return;
|
|
@@ -671,15 +1105,22 @@ const GuardVideoPlayerComponent = forwardRef((props, ref) => {
|
|
|
671
1105
|
apiBaseUrl,
|
|
672
1106
|
debug,
|
|
673
1107
|
autoplay,
|
|
674
|
-
controls,
|
|
675
|
-
className,
|
|
676
|
-
style,
|
|
1108
|
+
controls: false,
|
|
1109
|
+
className: '',
|
|
1110
|
+
style: {},
|
|
677
1111
|
hlsConfig,
|
|
678
1112
|
branding,
|
|
679
1113
|
contextMenuItems,
|
|
680
1114
|
security,
|
|
1115
|
+
viewerName,
|
|
1116
|
+
viewerEmail,
|
|
1117
|
+
forensicWatermark,
|
|
681
1118
|
onReady: () => {
|
|
682
1119
|
onReady?.();
|
|
1120
|
+
setTimeout(() => {
|
|
1121
|
+
const levels = player.getQualityLevels();
|
|
1122
|
+
setQualityLevels(levels);
|
|
1123
|
+
}, 100);
|
|
683
1124
|
},
|
|
684
1125
|
onError: (err) => {
|
|
685
1126
|
setError(err);
|
|
@@ -687,9 +1128,11 @@ const GuardVideoPlayerComponent = forwardRef((props, ref) => {
|
|
|
687
1128
|
},
|
|
688
1129
|
onQualityChange: (quality) => {
|
|
689
1130
|
onQualityChange?.(quality);
|
|
1131
|
+
const idx = player.getQualityLevels().findIndex(l => l.name === quality);
|
|
1132
|
+
setCurrentQualityIdx(idx);
|
|
690
1133
|
},
|
|
691
1134
|
onStateChange: (state) => {
|
|
692
|
-
|
|
1135
|
+
setPlayerState(state);
|
|
693
1136
|
onStateChange?.(state);
|
|
694
1137
|
},
|
|
695
1138
|
});
|
|
@@ -703,75 +1146,274 @@ const GuardVideoPlayerComponent = forwardRef((props, ref) => {
|
|
|
703
1146
|
const video = videoRef.current;
|
|
704
1147
|
if (!video)
|
|
705
1148
|
return;
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
|
|
1149
|
+
const onTimeUpdate = () => {
|
|
1150
|
+
setCurrentTime(video.currentTime);
|
|
1151
|
+
onTimeUpdateProp?.(video.currentTime);
|
|
1152
|
+
};
|
|
1153
|
+
const onDuration = () => setDuration(video.duration || 0);
|
|
1154
|
+
const onProgress = () => {
|
|
1155
|
+
if (video.buffered.length > 0) {
|
|
1156
|
+
setBuffered(video.buffered.end(video.buffered.length - 1));
|
|
709
1157
|
}
|
|
710
1158
|
};
|
|
711
|
-
const
|
|
1159
|
+
const onVolumeChange = () => {
|
|
1160
|
+
setVolume(video.volume);
|
|
1161
|
+
setMuted(video.muted);
|
|
1162
|
+
};
|
|
1163
|
+
const onEnded_ = () => {
|
|
712
1164
|
onEnded?.();
|
|
1165
|
+
setShowControls(true);
|
|
713
1166
|
};
|
|
714
|
-
video.
|
|
715
|
-
video.addEventListener('
|
|
1167
|
+
const onRateChange = () => setPlaybackRate(video.playbackRate);
|
|
1168
|
+
video.addEventListener('timeupdate', onTimeUpdate);
|
|
1169
|
+
video.addEventListener('loadedmetadata', onDuration);
|
|
1170
|
+
video.addEventListener('durationchange', onDuration);
|
|
1171
|
+
video.addEventListener('progress', onProgress);
|
|
1172
|
+
video.addEventListener('volumechange', onVolumeChange);
|
|
1173
|
+
video.addEventListener('ended', onEnded_);
|
|
1174
|
+
video.addEventListener('ratechange', onRateChange);
|
|
716
1175
|
return () => {
|
|
717
|
-
video.removeEventListener('timeupdate',
|
|
718
|
-
video.removeEventListener('
|
|
1176
|
+
video.removeEventListener('timeupdate', onTimeUpdate);
|
|
1177
|
+
video.removeEventListener('loadedmetadata', onDuration);
|
|
1178
|
+
video.removeEventListener('durationchange', onDuration);
|
|
1179
|
+
video.removeEventListener('progress', onProgress);
|
|
1180
|
+
video.removeEventListener('volumechange', onVolumeChange);
|
|
1181
|
+
video.removeEventListener('ended', onEnded_);
|
|
1182
|
+
video.removeEventListener('ratechange', onRateChange);
|
|
719
1183
|
};
|
|
720
|
-
}, [
|
|
1184
|
+
}, [onEnded, onTimeUpdateProp]);
|
|
1185
|
+
useEffect(() => {
|
|
1186
|
+
if (!forensicWatermark)
|
|
1187
|
+
return;
|
|
1188
|
+
const t = setTimeout(() => {
|
|
1189
|
+
const email = viewerEmail || viewerName || '';
|
|
1190
|
+
if (email)
|
|
1191
|
+
setWatermarkText(email);
|
|
1192
|
+
}, 1500);
|
|
1193
|
+
return () => clearTimeout(t);
|
|
1194
|
+
}, [forensicWatermark, viewerEmail, viewerName]);
|
|
1195
|
+
const resetHideTimer = useCallback(() => {
|
|
1196
|
+
setShowControls(true);
|
|
1197
|
+
if (hideTimer.current)
|
|
1198
|
+
clearTimeout(hideTimer.current);
|
|
1199
|
+
hideTimer.current = setTimeout(() => {
|
|
1200
|
+
if (playerState === PlayerState.PLAYING)
|
|
1201
|
+
setShowControls(false);
|
|
1202
|
+
}, 2800);
|
|
1203
|
+
}, [playerState]);
|
|
1204
|
+
useEffect(() => {
|
|
1205
|
+
if (playerState !== PlayerState.PLAYING) {
|
|
1206
|
+
setShowControls(true);
|
|
1207
|
+
if (hideTimer.current)
|
|
1208
|
+
clearTimeout(hideTimer.current);
|
|
1209
|
+
}
|
|
1210
|
+
else {
|
|
1211
|
+
resetHideTimer();
|
|
1212
|
+
}
|
|
1213
|
+
return () => { if (hideTimer.current)
|
|
1214
|
+
clearTimeout(hideTimer.current); };
|
|
1215
|
+
}, [playerState, resetHideTimer]);
|
|
1216
|
+
useEffect(() => {
|
|
1217
|
+
const onFsChange = () => setIsFullscreen(!!document.fullscreenElement);
|
|
1218
|
+
document.addEventListener('fullscreenchange', onFsChange);
|
|
1219
|
+
return () => document.removeEventListener('fullscreenchange', onFsChange);
|
|
1220
|
+
}, []);
|
|
1221
|
+
useEffect(() => {
|
|
1222
|
+
const onKey = (e) => {
|
|
1223
|
+
if (!containerRef.current?.contains(document.activeElement) &&
|
|
1224
|
+
document.activeElement !== containerRef.current)
|
|
1225
|
+
return;
|
|
1226
|
+
switch (e.code) {
|
|
1227
|
+
case 'Space':
|
|
1228
|
+
case 'KeyK':
|
|
1229
|
+
e.preventDefault();
|
|
1230
|
+
togglePlay();
|
|
1231
|
+
break;
|
|
1232
|
+
case 'ArrowLeft':
|
|
1233
|
+
e.preventDefault();
|
|
1234
|
+
playerRef.current?.seek(Math.max(0, (videoRef.current?.currentTime || 0) - 5));
|
|
1235
|
+
break;
|
|
1236
|
+
case 'ArrowRight':
|
|
1237
|
+
e.preventDefault();
|
|
1238
|
+
playerRef.current?.seek(Math.min(duration, (videoRef.current?.currentTime || 0) + 5));
|
|
1239
|
+
break;
|
|
1240
|
+
case 'ArrowUp':
|
|
1241
|
+
e.preventDefault();
|
|
1242
|
+
setVolume_(Math.min(1, volume + 0.1));
|
|
1243
|
+
break;
|
|
1244
|
+
case 'ArrowDown':
|
|
1245
|
+
e.preventDefault();
|
|
1246
|
+
setVolume_(Math.max(0, volume - 0.1));
|
|
1247
|
+
break;
|
|
1248
|
+
case 'KeyM':
|
|
1249
|
+
e.preventDefault();
|
|
1250
|
+
toggleMute();
|
|
1251
|
+
break;
|
|
1252
|
+
case 'KeyF':
|
|
1253
|
+
e.preventDefault();
|
|
1254
|
+
toggleFullscreen();
|
|
1255
|
+
break;
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
document.addEventListener('keydown', onKey);
|
|
1259
|
+
return () => document.removeEventListener('keydown', onKey);
|
|
1260
|
+
}, [duration, volume]);
|
|
721
1261
|
useImperativeHandle(ref, () => ({
|
|
722
1262
|
play: () => playerRef.current?.play() || Promise.resolve(),
|
|
723
1263
|
pause: () => playerRef.current?.pause(),
|
|
724
1264
|
getCurrentTime: () => playerRef.current?.getCurrentTime() || 0,
|
|
725
|
-
seek: (
|
|
1265
|
+
seek: (t) => playerRef.current?.seek(t),
|
|
726
1266
|
getDuration: () => playerRef.current?.getDuration() || 0,
|
|
727
1267
|
getVolume: () => playerRef.current?.getVolume() || 1,
|
|
728
|
-
setVolume: (
|
|
1268
|
+
setVolume: (v) => playerRef.current?.setVolume(v),
|
|
729
1269
|
getQualityLevels: () => playerRef.current?.getQualityLevels() || [],
|
|
730
1270
|
getCurrentQuality: () => playerRef.current?.getCurrentQuality() || null,
|
|
731
|
-
setQuality: (
|
|
1271
|
+
setQuality: (i) => playerRef.current?.setQuality(i),
|
|
732
1272
|
getState: () => playerRef.current?.getState() || PlayerState.IDLE,
|
|
733
1273
|
destroy: () => playerRef.current?.destroy(),
|
|
734
1274
|
getVideoElement: () => videoRef.current,
|
|
735
1275
|
}));
|
|
736
|
-
const
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
1276
|
+
const togglePlay = useCallback(() => {
|
|
1277
|
+
const video = videoRef.current;
|
|
1278
|
+
if (!video)
|
|
1279
|
+
return;
|
|
1280
|
+
if (video.paused || video.ended) {
|
|
1281
|
+
playerRef.current?.play().catch(() => { });
|
|
1282
|
+
}
|
|
1283
|
+
else {
|
|
1284
|
+
playerRef.current?.pause();
|
|
1285
|
+
}
|
|
1286
|
+
resetHideTimer();
|
|
1287
|
+
}, [resetHideTimer]);
|
|
1288
|
+
const setVolume_ = useCallback((v) => {
|
|
1289
|
+
if (!videoRef.current)
|
|
1290
|
+
return;
|
|
1291
|
+
videoRef.current.volume = v;
|
|
1292
|
+
videoRef.current.muted = v === 0;
|
|
1293
|
+
}, []);
|
|
1294
|
+
const toggleMute = useCallback(() => {
|
|
1295
|
+
if (!videoRef.current)
|
|
1296
|
+
return;
|
|
1297
|
+
videoRef.current.muted = !videoRef.current.muted;
|
|
1298
|
+
}, []);
|
|
1299
|
+
const toggleFullscreen = useCallback(() => {
|
|
1300
|
+
const el = containerRef.current;
|
|
1301
|
+
if (!el)
|
|
1302
|
+
return;
|
|
1303
|
+
if (document.fullscreenElement) {
|
|
1304
|
+
document.exitFullscreen().catch(() => { });
|
|
1305
|
+
}
|
|
1306
|
+
else {
|
|
1307
|
+
el.requestFullscreen().catch(() => { });
|
|
1308
|
+
}
|
|
1309
|
+
}, []);
|
|
1310
|
+
const getSeekedTime = (e) => {
|
|
1311
|
+
const rect = seekRef.current.getBoundingClientRect();
|
|
1312
|
+
const clientX = 'touches' in e ? e.touches[0].clientX : e.clientX;
|
|
1313
|
+
const pct = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
1314
|
+
return pct * duration;
|
|
1315
|
+
};
|
|
1316
|
+
const onSeekClick = (e) => {
|
|
1317
|
+
const t = getSeekedTime(e);
|
|
1318
|
+
playerRef.current?.seek(t);
|
|
1319
|
+
resetHideTimer();
|
|
742
1320
|
};
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
1321
|
+
const onSeekMouseMove = (e) => {
|
|
1322
|
+
const rect = seekRef.current.getBoundingClientRect();
|
|
1323
|
+
const pct = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
|
1324
|
+
setSeekTooltip({ pct, time: formatTime(pct * duration) });
|
|
1325
|
+
};
|
|
1326
|
+
const onSeekMouseLeave = () => setSeekTooltip(null);
|
|
1327
|
+
const addRipple = (e) => {
|
|
1328
|
+
const el = containerRef.current;
|
|
1329
|
+
if (!el)
|
|
1330
|
+
return;
|
|
1331
|
+
const rect = el.getBoundingClientRect();
|
|
1332
|
+
const d = document.createElement('div');
|
|
1333
|
+
d.className = 'gvp-ripple';
|
|
1334
|
+
const size = 60;
|
|
1335
|
+
d.style.cssText = `width:${size}px;height:${size}px;left:${e.clientX - rect.left - size / 2}px;top:${e.clientY - rect.top - size / 2}px`;
|
|
1336
|
+
el.appendChild(d);
|
|
1337
|
+
setTimeout(() => d.remove(), 600);
|
|
747
1338
|
};
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
1339
|
+
const progressPct = duration > 0 ? (currentTime / duration) * 100 : 0;
|
|
1340
|
+
const bufferedPct = duration > 0 ? (buffered / duration) * 100 : 0;
|
|
1341
|
+
const isLoading = playerState === PlayerState.LOADING || playerState === PlayerState.BUFFERING;
|
|
1342
|
+
const isIdle = playerState === PlayerState.IDLE;
|
|
1343
|
+
const isPlaying = playerState === PlayerState.PLAYING;
|
|
1344
|
+
const isEnded = videoRef.current?.ended ?? false;
|
|
1345
|
+
const controlsVisible = showControls || !isPlaying;
|
|
1346
|
+
const SPEEDS = [0.5, 0.75, 1, 1.25, 1.5, 2];
|
|
1347
|
+
return (React.createElement("div", { ref: containerRef, className: `gvp-root${className ? ` ${className}` : ''}`, style: { width, height, ...style }, tabIndex: 0, onMouseMove: resetHideTimer, onMouseLeave: () => isPlaying && setShowControls(false), onClick: () => setShowMenu(null) },
|
|
1348
|
+
React.createElement("video", { ref: videoRef, className: "gvp-video", playsInline: true, preload: "metadata" }),
|
|
1349
|
+
React.createElement("div", { className: `gvp-badge${controlsVisible ? '' : ' gvp-badge-hidden'}` },
|
|
1350
|
+
React.createElement(ShieldIcon, { color: accentColor }),
|
|
1351
|
+
brandName),
|
|
1352
|
+
forensicWatermark && watermarkText && (React.createElement("div", { className: "gvp-watermark" }, Array.from({ length: 20 }).map((_, i) => (React.createElement("span", { key: i, className: "gvp-watermark-text", style: {
|
|
1353
|
+
left: `${(i % 4) * 26 + ((Math.floor(i / 4)) % 2) * 13}%`,
|
|
1354
|
+
top: `${Math.floor(i / 4) * 22}%`,
|
|
1355
|
+
} }, watermarkText))))),
|
|
1356
|
+
isLoading && (React.createElement("div", { className: "gvp-spinner" },
|
|
1357
|
+
React.createElement("div", { className: "gvp-spinner-ring" }))),
|
|
1358
|
+
error && (React.createElement("div", { className: "gvp-error" },
|
|
1359
|
+
React.createElement("div", { className: "gvp-error-icon" }, "\u26A0\uFE0F"),
|
|
1360
|
+
React.createElement("div", { className: "gvp-error-code" }, error.code),
|
|
1361
|
+
React.createElement("div", { className: "gvp-error-msg" }, error.message))),
|
|
1362
|
+
(isIdle || isEnded) && !error && !isLoading && (React.createElement("div", { className: "gvp-center-play", onClick: togglePlay },
|
|
1363
|
+
React.createElement("div", { className: "gvp-center-play-btn" }, isEnded ? React.createElement(ReplayIcon, null) : React.createElement(PlayIcon, null)))),
|
|
1364
|
+
!isIdle && !error && (React.createElement("div", { className: "gvp-click-area", onClick: (e) => { addRipple(e); togglePlay(); } })),
|
|
1365
|
+
!error && (React.createElement("div", { className: `gvp-controls${controlsVisible ? '' : ' gvp-controls-hidden'}` },
|
|
1366
|
+
React.createElement("div", { className: "gvp-seek-row" },
|
|
1367
|
+
React.createElement("div", { ref: seekRef, className: "gvp-seek-wrap", onClick: onSeekClick, onMouseMove: onSeekMouseMove, onMouseLeave: onSeekMouseLeave },
|
|
1368
|
+
React.createElement("div", { className: "gvp-seek-track" },
|
|
1369
|
+
React.createElement("div", { className: "gvp-seek-buffered", style: { width: `${bufferedPct}%` } }),
|
|
1370
|
+
React.createElement("div", { className: "gvp-seek-progress", style: { width: `${progressPct}%` } })),
|
|
1371
|
+
React.createElement("div", { className: "gvp-seek-thumb", style: { left: `${progressPct}%` } }),
|
|
1372
|
+
seekTooltip && (React.createElement("div", { className: "gvp-seek-tooltip", style: { left: `${seekTooltip.pct * 100}%` } }, seekTooltip.time)))),
|
|
1373
|
+
React.createElement("div", { className: "gvp-btn-row" },
|
|
1374
|
+
React.createElement("button", { className: "gvp-btn", onClick: togglePlay, title: isPlaying ? 'Pause (k)' : 'Play (k)' }, isEnded ? React.createElement(ReplayIcon, null) : isPlaying ? React.createElement(PauseIcon, null) : React.createElement(PlayIcon, null)),
|
|
1375
|
+
React.createElement("div", { className: "gvp-volume-wrap" },
|
|
1376
|
+
React.createElement("button", { className: "gvp-btn", onClick: toggleMute, title: "Mute (m)" }, muted || volume === 0 ? React.createElement(VolumeMuteIcon, null) : React.createElement(VolumeHighIcon, null)),
|
|
1377
|
+
React.createElement("input", { type: "range", className: "gvp-volume-slider", min: 0, max: 1, step: 0.02, value: muted ? 0 : volume, onChange: (e) => setVolume_(parseFloat(e.target.value)), title: "Volume" })),
|
|
1378
|
+
React.createElement("span", { className: "gvp-time" },
|
|
1379
|
+
formatTime(currentTime),
|
|
1380
|
+
"\u00A0",
|
|
1381
|
+
React.createElement("span", { style: { opacity: 0.45 } }, "/"),
|
|
1382
|
+
"\u00A0",
|
|
1383
|
+
formatTime(duration)),
|
|
1384
|
+
React.createElement("div", { className: "gvp-spacer" }),
|
|
1385
|
+
React.createElement("div", { className: "gvp-menu-wrap" },
|
|
1386
|
+
React.createElement("span", { className: "gvp-rate-label", title: "Playback speed", onClick: (e) => { e.stopPropagation(); setShowMenu(showMenu === 'speed' ? null : 'speed'); } }, playbackRate === 1 ? '1×' : `${playbackRate}×`),
|
|
1387
|
+
showMenu === 'speed' && (React.createElement("div", { className: "gvp-menu", onClick: (e) => e.stopPropagation() },
|
|
1388
|
+
React.createElement("div", { className: "gvp-menu-title" }, "Speed"),
|
|
1389
|
+
SPEEDS.map((r) => (React.createElement("div", { key: r, className: `gvp-menu-item${playbackRate === r ? ' gvp-menu-item-active' : ''}`, onClick: () => {
|
|
1390
|
+
if (videoRef.current)
|
|
1391
|
+
videoRef.current.playbackRate = r;
|
|
1392
|
+
setShowMenu(null);
|
|
1393
|
+
} },
|
|
1394
|
+
r === 1 ? 'Normal' : `${r}×`,
|
|
1395
|
+
playbackRate === r && React.createElement("span", { className: "gvp-menu-check" }, "\u2713"))))))),
|
|
1396
|
+
qualityLevels.length > 0 && (React.createElement("div", { className: "gvp-menu-wrap" },
|
|
1397
|
+
React.createElement("button", { className: "gvp-btn", title: "Quality settings", onClick: (e) => { e.stopPropagation(); setShowMenu(showMenu === 'quality' ? null : 'quality'); } },
|
|
1398
|
+
React.createElement(SettingsIcon, null)),
|
|
1399
|
+
showMenu === 'quality' && (React.createElement("div", { className: "gvp-menu", onClick: (e) => e.stopPropagation() },
|
|
1400
|
+
React.createElement("div", { className: "gvp-menu-title" }, "Quality"),
|
|
1401
|
+
React.createElement("div", { className: `gvp-menu-item${currentQualityIdx === -1 ? ' gvp-menu-item-active' : ''}`, onClick: () => {
|
|
1402
|
+
playerRef.current?.setQuality(-1);
|
|
1403
|
+
setCurrentQualityIdx(-1);
|
|
1404
|
+
setShowMenu(null);
|
|
1405
|
+
} },
|
|
1406
|
+
"Auto",
|
|
1407
|
+
currentQualityIdx === -1 && React.createElement("span", { className: "gvp-menu-check" }, "\u2713")),
|
|
1408
|
+
React.createElement("div", { className: "gvp-menu-sep" }),
|
|
1409
|
+
[...qualityLevels].reverse().map((q) => (React.createElement("div", { key: q.index, className: `gvp-menu-item${currentQualityIdx === q.index ? ' gvp-menu-item-active' : ''}`, onClick: () => {
|
|
1410
|
+
playerRef.current?.setQuality(q.index);
|
|
1411
|
+
setCurrentQualityIdx(q.index);
|
|
1412
|
+
setShowMenu(null);
|
|
1413
|
+
} },
|
|
1414
|
+
q.name,
|
|
1415
|
+
currentQualityIdx === q.index && React.createElement("span", { className: "gvp-menu-check" }, "\u2713")))))))),
|
|
1416
|
+
React.createElement("button", { className: "gvp-btn", onClick: toggleFullscreen, title: "Fullscreen (f)" }, isFullscreen ? React.createElement(ExitFullscreenIcon, null) : React.createElement(FullscreenIcon, null)))))));
|
|
775
1417
|
});
|
|
776
1418
|
GuardVideoPlayerComponent.displayName = 'GuardVideoPlayer';
|
|
777
1419
|
|