@webitch/player 0.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.
Files changed (108) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +36 -0
  3. package/dist/app/global.scss +47 -0
  4. package/dist/app/layout.d.ts +5 -0
  5. package/dist/app/layout.d.ts.map +1 -0
  6. package/dist/app/layout.js +12 -0
  7. package/dist/app/page.d.ts +2 -0
  8. package/dist/app/page.d.ts.map +1 -0
  9. package/dist/app/page.js +29 -0
  10. package/dist/assets/images/png/backward_10.png +0 -0
  11. package/dist/assets/images/png/forward10_Bold.png +0 -0
  12. package/dist/assets/images/png/forward_10.png +0 -0
  13. package/dist/assets/images/png/full-screen-off.png +0 -0
  14. package/dist/assets/images/png/full-screen-on.png +0 -0
  15. package/dist/assets/images/png/picture-in-picture.png +0 -0
  16. package/dist/assets/images/png/play-btn.png +0 -0
  17. package/dist/assets/images/png/rewind10_Bold.png +0 -0
  18. package/dist/assets/images/png/settings-icon.png +0 -0
  19. package/dist/assets/images/png/sound-off.png +0 -0
  20. package/dist/assets/images/png/sound.png +0 -0
  21. package/dist/assets/images/png/stop-btn.png +0 -0
  22. package/dist/assets/images/png/subtitle.png +0 -0
  23. package/dist/component.d.ts +25 -0
  24. package/dist/component.d.ts.map +1 -0
  25. package/dist/component.js +110 -0
  26. package/dist/entites/play-buttons/index.d.ts +2 -0
  27. package/dist/entites/play-buttons/index.d.ts.map +1 -0
  28. package/dist/entites/play-buttons/index.js +1 -0
  29. package/dist/entites/play-buttons/lib/handlers.d.ts +4 -0
  30. package/dist/entites/play-buttons/lib/handlers.d.ts.map +1 -0
  31. package/dist/entites/play-buttons/lib/handlers.js +12 -0
  32. package/dist/entites/play-buttons/ui/play-buttons.d.ts +7 -0
  33. package/dist/entites/play-buttons/ui/play-buttons.d.ts.map +1 -0
  34. package/dist/entites/play-buttons/ui/play-buttons.js +84 -0
  35. package/dist/entites/play-buttons/ui/styles.module.scss +65 -0
  36. package/dist/entites/progress-bar/index.d.ts +2 -0
  37. package/dist/entites/progress-bar/index.d.ts.map +1 -0
  38. package/dist/entites/progress-bar/index.js +1 -0
  39. package/dist/entites/progress-bar/lib/handlers.d.ts +16 -0
  40. package/dist/entites/progress-bar/lib/handlers.d.ts.map +1 -0
  41. package/dist/entites/progress-bar/lib/handlers.js +97 -0
  42. package/dist/entites/progress-bar/ui/progress-bar.d.ts +11 -0
  43. package/dist/entites/progress-bar/ui/progress-bar.d.ts.map +1 -0
  44. package/dist/entites/progress-bar/ui/progress-bar.js +140 -0
  45. package/dist/entites/progress-bar/ui/styles.module.scss +91 -0
  46. package/dist/entites/settings-buttons/index.d.ts +2 -0
  47. package/dist/entites/settings-buttons/index.d.ts.map +1 -0
  48. package/dist/entites/settings-buttons/index.js +1 -0
  49. package/dist/entites/settings-buttons/lib/handlers.d.ts +9 -0
  50. package/dist/entites/settings-buttons/lib/handlers.d.ts.map +1 -0
  51. package/dist/entites/settings-buttons/lib/handlers.js +42 -0
  52. package/dist/entites/settings-buttons/models/settings-buttons.interface.d.ts +6 -0
  53. package/dist/entites/settings-buttons/models/settings-buttons.interface.d.ts.map +1 -0
  54. package/dist/entites/settings-buttons/models/settings-buttons.interface.js +1 -0
  55. package/dist/entites/settings-buttons/ui/setting-buttons.d.ts +3 -0
  56. package/dist/entites/settings-buttons/ui/setting-buttons.d.ts.map +1 -0
  57. package/dist/entites/settings-buttons/ui/setting-buttons.js +173 -0
  58. package/dist/entites/settings-buttons/ui/styles.module.scss +135 -0
  59. package/dist/entites/sound-volume/index.d.ts +2 -0
  60. package/dist/entites/sound-volume/index.d.ts.map +1 -0
  61. package/dist/entites/sound-volume/index.js +1 -0
  62. package/dist/entites/sound-volume/lib/handlers.d.ts +6 -0
  63. package/dist/entites/sound-volume/lib/handlers.d.ts.map +1 -0
  64. package/dist/entites/sound-volume/lib/handlers.js +27 -0
  65. package/dist/entites/sound-volume/ui/sound-volume.d.ts +9 -0
  66. package/dist/entites/sound-volume/ui/sound-volume.d.ts.map +1 -0
  67. package/dist/entites/sound-volume/ui/sound-volume.js +113 -0
  68. package/dist/entites/sound-volume/ui/styles.module.scss +124 -0
  69. package/dist/features/player-tools/lib/handlers.d.ts +3 -0
  70. package/dist/features/player-tools/lib/handlers.d.ts.map +1 -0
  71. package/dist/features/player-tools/lib/handlers.js +7 -0
  72. package/dist/features/player-tools/model/player-tools.interface.d.ts +9 -0
  73. package/dist/features/player-tools/model/player-tools.interface.d.ts.map +1 -0
  74. package/dist/features/player-tools/model/player-tools.interface.js +1 -0
  75. package/dist/features/player-tools/ui/player-tools.d.ts +3 -0
  76. package/dist/features/player-tools/ui/player-tools.d.ts.map +1 -0
  77. package/dist/features/player-tools/ui/player-tools.js +48 -0
  78. package/dist/features/player-tools/ui/styles.module.scss +90 -0
  79. package/dist/index.d.ts +2 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +1 -0
  82. package/dist/shared/constants/svgs.d.ts +17 -0
  83. package/dist/shared/constants/svgs.d.ts.map +1 -0
  84. package/dist/shared/constants/svgs.js +16 -0
  85. package/dist/shared/ui/Svg/index.d.ts +13 -0
  86. package/dist/shared/ui/Svg/index.d.ts.map +1 -0
  87. package/dist/shared/ui/Svg/index.js +170 -0
  88. package/dist/shared/ui/index.d.ts +3 -0
  89. package/dist/shared/ui/index.d.ts.map +1 -0
  90. package/dist/shared/ui/index.js +2 -0
  91. package/dist/shared/ui/modal/modal.d.ts +19 -0
  92. package/dist/shared/ui/modal/modal.d.ts.map +1 -0
  93. package/dist/shared/ui/modal/modal.js +39 -0
  94. package/dist/shared/ui/modal/styles.module.scss +21 -0
  95. package/dist/shared/utils/getHHSStime.d.ts +2 -0
  96. package/dist/shared/utils/getHHSStime.d.ts.map +1 -0
  97. package/dist/shared/utils/getHHSStime.js +20 -0
  98. package/dist/widget/video-tag/lib/handlers.d.ts +6 -0
  99. package/dist/widget/video-tag/lib/handlers.d.ts.map +1 -0
  100. package/dist/widget/video-tag/lib/handlers.js +21 -0
  101. package/dist/widget/video-tag/model/video-tag.interface.d.ts +16 -0
  102. package/dist/widget/video-tag/model/video-tag.interface.d.ts.map +1 -0
  103. package/dist/widget/video-tag/model/video-tag.interface.js +1 -0
  104. package/dist/widget/video-tag/ui/styles.module.scss +16 -0
  105. package/dist/widget/video-tag/ui/video-tag.d.ts +3 -0
  106. package/dist/widget/video-tag/ui/video-tag.d.ts.map +1 -0
  107. package/dist/widget/video-tag/ui/video-tag.js +38 -0
  108. package/package.json +53 -0
@@ -0,0 +1,65 @@
1
+ .toolsBtns {
2
+ bottom: 0%;
3
+ left: 2%;
4
+ z-index: 10;
5
+ height: 100%;
6
+ display: flex;
7
+ align-items: center;
8
+ align-self: center;
9
+ align-content: center;
10
+ top: 105%;
11
+ }
12
+
13
+ .playBtnWrap {
14
+ background-color: rgb(0, 0, 0, 0.3);
15
+ user-select: none;
16
+ border: none;
17
+ cursor: pointer;
18
+ transition: all 0.2s ease;
19
+ border-radius: 28px;
20
+ padding: 3px 3px 3px 3px;
21
+ }
22
+
23
+ .playBtn {
24
+ background-color: rgb(0, 0, 0, 0.0);
25
+ user-select: none;
26
+ border: none;
27
+ transition: all 0.2s ease;
28
+ border-radius: 28px;
29
+ padding: 2px 6px 2px 6px;
30
+
31
+ &:hover {
32
+ background-color: rgb(255, 255, 255, 0.1);
33
+ }
34
+ }
35
+
36
+ .replaceVideoBtns {
37
+ background-color: rgb(0, 0, 0, 0.3);
38
+ border-radius: 28px;
39
+ padding: 4px 4px 4px 4px;
40
+ align-items: center;
41
+ display: flex;
42
+ gap: 0px;
43
+ }
44
+
45
+ .forwardBtn {
46
+ background: none;
47
+ border-radius: 28px;
48
+ padding: 4px 16px 0px 16px;
49
+ border: none;
50
+ color: #fff;
51
+ cursor: pointer;
52
+ user-select: none;
53
+
54
+ &:hover {
55
+ background-color: rgb(255, 255, 255, 0.1);
56
+ }
57
+ }
58
+
59
+ .rewindBtn {
60
+ background: none;
61
+ border: none;
62
+ color: #fff;
63
+ cursor: pointer;
64
+ user-select: none;
65
+ }
@@ -0,0 +1,2 @@
1
+ export { ProgressBar } from './ui/progress-bar';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entites/progress-bar/index.ts"],"names":[],"mappings":"AAAA,OAAQ,EAAC,WAAW,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1 @@
1
+ export { ProgressBar } from './ui/progress-bar';
@@ -0,0 +1,16 @@
1
+ import { IFragment } from "@/widget/video-tag/model/video-tag.interface";
2
+ import { Dispatch, JSX, RefObject, SetStateAction } from "react";
3
+ export declare const handleMouseOver: (e: React.MouseEvent, isDragging: boolean, duration: number, progressContainerRef: RefObject<HTMLDivElement | null>, setHoverTime: (newHoverTime: number) => void) => void;
4
+ export declare const handleClick: (e: React.MouseEvent, isDragging: boolean, duration: number, progressContainerRef: RefObject<HTMLDivElement | null>, videoRef: RefObject<HTMLMediaElement>, setCurrentVideoTime: (newCurrentVideoTime: number) => void) => void;
5
+ export declare const handleMouseDown: (e: React.MouseEvent, setIsDragging: Dispatch<SetStateAction<boolean>>) => void;
6
+ export interface ProgressBarFragmentProps {
7
+ duration: number;
8
+ fragments: IFragment[] | null | undefined;
9
+ bufferedFragments: Array<{
10
+ start: number;
11
+ end: number;
12
+ }>;
13
+ currentVideoTime: number;
14
+ }
15
+ export declare const getProgressBarFragments: ({ duration, fragments, bufferedFragments, currentVideoTime, }: ProgressBarFragmentProps) => JSX.Element[];
16
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../../src/entites/progress-bar/lib/handlers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,cAAc,EAAW,MAAM,OAAO,CAAA;AAIzE,eAAO,MAAM,eAAe,GAAI,GAAG,KAAK,CAAC,UAAU,EAAE,YAAY,OAAO,EAAE,UAAU,MAAM,EAAE,sBAAsB,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,cAAc,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,SAO/L,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,GAAG,KAAK,CAAC,UAAU,EAAE,YAAY,OAAO,EAAE,UAAU,MAAM,EAAE,sBAAsB,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,UAAU,SAAS,CAAC,gBAAgB,CAAC,EAAE,qBAAqB,CAAC,mBAAmB,EAAE,MAAM,KAAK,IAAI,SAShP,CAAC;AAEF,eAAO,MAAM,eAAe,GACxB,GAAG,KAAK,CAAC,UAAU,EACnB,eAAe,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,SAMnD,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,iBAAiB,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,uBAAuB,GAAI,+DAKrC,wBAAwB,kBAuH1B,CAAC"}
@@ -0,0 +1,97 @@
1
+ import styles from '../ui/styles.module.scss';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export const handleMouseOver = (e, isDragging, duration, progressContainerRef, setHoverTime) => {
4
+ if (!isDragging && progressContainerRef.current && duration) {
5
+ const rect = progressContainerRef.current.getBoundingClientRect();
6
+ const clickPosition = Math.min(Math.max(e.clientX - rect.left, 0), rect.width);
7
+ const newTime = clickPosition / rect.width * duration;
8
+ setHoverTime(newTime);
9
+ }
10
+ };
11
+ export const handleClick = (e, isDragging, duration, progressContainerRef, videoRef, setCurrentVideoTime) => {
12
+ if (!isDragging && progressContainerRef.current && duration) {
13
+ const rect = progressContainerRef.current.getBoundingClientRect();
14
+ const clickPosition = Math.min(Math.max(e.clientX - rect.left, 0), rect.width);
15
+ const newTime = clickPosition / rect.width * duration;
16
+ videoRef.current.currentTime = newTime;
17
+ setCurrentVideoTime(newTime);
18
+ }
19
+ };
20
+ export const handleMouseDown = (e, setIsDragging) => {
21
+ e.preventDefault();
22
+ console.log('handleMouseDown');
23
+ setIsDragging(true);
24
+ };
25
+ export const getProgressBarFragments = ({
26
+ duration,
27
+ fragments,
28
+ bufferedFragments,
29
+ currentVideoTime
30
+ }) => {
31
+ const elements = [];
32
+ const getGradientStops = (start, end, progress, buffers) => {
33
+ const gradientStops = [];
34
+ const progressPercent = progress >= end ? 100 : progress > start ? (progress - start) / (end - start) * 100 : 0;
35
+ if (progressPercent > 0) {
36
+ gradientStops.push("#1e90ff 0%");
37
+ gradientStops.push(`#1e90ff ${progressPercent}%`);
38
+ gradientStops.push(`#444 ${progressPercent}%`);
39
+ } else {
40
+ gradientStops.push("#444 0%");
41
+ }
42
+ const bufferStops = [];
43
+ buffers.forEach(buffered => {
44
+ const overlapStart = Math.max(start, buffered.start);
45
+ const overlapEnd = Math.min(end, buffered.end);
46
+ if (overlapStart < overlapEnd) {
47
+ const bufferStartPercent = (overlapStart - start) / (end - start) * 100;
48
+ const bufferEndPercent = (overlapEnd - start) / (end - start) * 100;
49
+ if (bufferEndPercent > progressPercent) {
50
+ bufferStops.push({
51
+ start: Math.max(bufferStartPercent, progressPercent),
52
+ end: bufferEndPercent
53
+ });
54
+ }
55
+ }
56
+ });
57
+ bufferStops.forEach(buffer => {
58
+ gradientStops.push(`#666 ${buffer.start}%`);
59
+ gradientStops.push(`#666 ${buffer.end}%`);
60
+ });
61
+ const lastValue = gradientStops.length > 0 ? parseFloat(gradientStops[gradientStops.length - 1].split(" ")[1].replace("%", "")) : 0;
62
+ if (lastValue < 100) {
63
+ gradientStops.push(`#444 ${Math.max(lastValue, progressPercent)}%`);
64
+ gradientStops.push(`#444 100%`);
65
+ }
66
+ return gradientStops;
67
+ };
68
+ if (!duration || !fragments || fragments.length === 0) {
69
+ const gradientStops = getGradientStops(0, duration || 100, currentVideoTime, bufferedFragments);
70
+ const gradient = `linear-gradient(to right, ${gradientStops.join(", ")})`;
71
+ elements.push(_jsx("div", {
72
+ className: styles.fragment,
73
+ style: {
74
+ left: "0%",
75
+ width: "100%",
76
+ background: gradient
77
+ }
78
+ }, "single-fragment"));
79
+ return elements;
80
+ }
81
+ fragments.forEach((fragment, index) => {
82
+ const fragmentStartPercent = fragment.start / duration * 100;
83
+ const fragmentEndPercent = fragment.end / duration * 100;
84
+ const fragmentWidthPercent = fragmentEndPercent - fragmentStartPercent;
85
+ const gradientStops = getGradientStops(fragment.start, fragment.end, currentVideoTime, bufferedFragments);
86
+ const gradient = `linear-gradient(to right, ${gradientStops.join(", ")})`;
87
+ elements.push(_jsx("div", {
88
+ className: styles.fragment,
89
+ style: {
90
+ left: `${fragmentStartPercent}%`,
91
+ width: `${fragmentWidthPercent}%`,
92
+ background: gradient
93
+ }
94
+ }, index));
95
+ });
96
+ return elements;
97
+ };
@@ -0,0 +1,11 @@
1
+ import { RefObject } from "react";
2
+ import { IFragment } from "../../../widget/video-tag/model/video-tag.interface";
3
+ interface IProgressBar {
4
+ duration: number;
5
+ videoRef: RefObject<HTMLVideoElement>;
6
+ fragments?: IFragment[];
7
+ isLiveStream?: boolean;
8
+ }
9
+ export declare const ProgressBar: React.FC<IProgressBar>;
10
+ export {};
11
+ //# sourceMappingURL=progress-bar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-bar.d.ts","sourceRoot":"","sources":["../../../../src/entites/progress-bar/ui/progress-bar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,SAAS,EAAwC,MAAM,OAAO,CAAC;AAI7E,OAAO,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAWhF,UAAU,YAAY;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;CACzB;AAOD,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA0K9C,CAAC"}
@@ -0,0 +1,140 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { usePlayerContext } from "../../../component";
5
+ import { getHHSStime } from "../../../shared/utils/getHHSStime";
6
+ import { getProgressBarFragments, handleClick, handleMouseDown, handleMouseOver } from "../lib/handlers";
7
+ import styles from './styles.module.scss';
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ export const ProgressBar = ({
10
+ duration,
11
+ videoRef,
12
+ fragments,
13
+ isLiveStream
14
+ }) => {
15
+ const [hoverTime, setHoverTime] = useState(0);
16
+ const [isDragging, setIsDragging] = useState(false);
17
+ const [bufferedFragments, setBufferedFragments] = useState([]);
18
+ const [currentVideoTime, setCurrentVideoTime] = useState(0);
19
+ const progressContainerRef = useRef(null);
20
+ const animationFrameRef = useRef(0);
21
+ const context = usePlayerContext();
22
+ useEffect(() => {
23
+ const video = videoRef.current;
24
+ if (!video || isDragging) return;
25
+ const updateTime = () => {
26
+ setCurrentVideoTime(video.currentTime);
27
+ animationFrameRef.current = requestAnimationFrame(updateTime);
28
+ };
29
+ animationFrameRef.current = requestAnimationFrame(updateTime);
30
+ return () => {
31
+ if (animationFrameRef.current) {
32
+ cancelAnimationFrame(animationFrameRef.current);
33
+ }
34
+ };
35
+ }, [videoRef, duration, isDragging]);
36
+ useEffect(() => {
37
+ if (!isDragging) return;
38
+ let isUpdating = false;
39
+ const handleMouseMoveWrapper = e => {
40
+ if (!progressContainerRef.current || !duration || isUpdating) return;
41
+ isUpdating = true;
42
+ context.setIsPaused(true);
43
+ requestAnimationFrame(() => {
44
+ const rect = progressContainerRef.current.getBoundingClientRect();
45
+ const clickPosition = Math.min(Math.max(e.clientX - rect.left, 0), rect.width);
46
+ const clickPercentage = clickPosition / rect.width;
47
+ const newTime = clickPercentage * duration;
48
+ setCurrentVideoTime(newTime);
49
+ videoRef.current.currentTime = newTime;
50
+ setHoverTime(newTime);
51
+ const timeHoverPosition = document.getElementById('timeHover');
52
+ if (timeHoverPosition) {
53
+ timeHoverPosition.style.left = `${clickPosition}px`;
54
+ }
55
+ isUpdating = false;
56
+ });
57
+ };
58
+ const handleMouseUpWrapper = e => {
59
+ if (!progressContainerRef.current || !videoRef.current || !duration) return;
60
+ const rect = progressContainerRef.current.getBoundingClientRect();
61
+ const clickPosition = Math.min(Math.max(e.clientX - rect.left, 0), rect.width);
62
+ const clickPercentage = clickPosition / rect.width;
63
+ const newTime = clickPercentage * duration;
64
+ videoRef.current.currentTime = newTime;
65
+ setCurrentVideoTime(newTime);
66
+ setHoverTime(0);
67
+ setIsDragging(false);
68
+ };
69
+ const playerContainer = document.documentElement;
70
+ if (!playerContainer) return;
71
+ playerContainer.addEventListener('mousemove', handleMouseMoveWrapper, {
72
+ passive: true
73
+ });
74
+ playerContainer.addEventListener('mouseup', handleMouseUpWrapper, {
75
+ passive: true
76
+ });
77
+ return () => {
78
+ playerContainer.removeEventListener('mousemove', handleMouseMoveWrapper);
79
+ playerContainer.removeEventListener('mouseup', handleMouseUpWrapper);
80
+ };
81
+ }, [isDragging, duration, videoRef, context]);
82
+ useEffect(() => {
83
+ if (!videoRef?.current) return;
84
+ const videoElement = videoRef.current;
85
+ const updateBufferedRanges = () => {
86
+ const fragments = [];
87
+ for (let index = 0; index < videoElement.buffered.length; index++) {
88
+ fragments.push({
89
+ start: videoElement.buffered.start(index),
90
+ end: videoElement.buffered.end(index)
91
+ });
92
+ }
93
+ setBufferedFragments(fragments);
94
+ };
95
+ videoElement.addEventListener('progress', updateBufferedRanges);
96
+ videoElement.addEventListener('loadeddata', updateBufferedRanges);
97
+ return () => {
98
+ videoElement.removeEventListener('progress', updateBufferedRanges);
99
+ videoElement.removeEventListener('loadeddata', updateBufferedRanges);
100
+ };
101
+ }, [videoRef]);
102
+ if (isLiveStream || !duration) return _jsx("div", {
103
+ children: "\u044D\u0442\u043E \u0441\u0442\u0440\u0438\u043C, \u043D\u0443\u0436\u043D\u043E \u043F\u0435\u0440\u0435\u0434\u0435\u043B\u0430\u0442\u044C \u043F\u0440\u043E\u0433\u0440\u0435\u0441 \u0431\u0430\u0440"
104
+ });
105
+ return _jsxs("div", {
106
+ className: styles.progressBarContainer,
107
+ children: [_jsx("div", {
108
+ id: "timeHover",
109
+ className: hoverTime ? styles.progressTimeHover : styles.progressTimeHover_hidden,
110
+ style: {
111
+ left: `${hoverTime / duration * 100}%`,
112
+ display: hoverTime ? 'block' : 'none'
113
+ },
114
+ children: getHHSStime(Math.trunc(hoverTime))
115
+ }), _jsx("div", {
116
+ id: "progressBar",
117
+ ref: progressContainerRef,
118
+ className: styles.progressContainer,
119
+ onClick: e => handleClick(e, isDragging, duration, progressContainerRef, videoRef, setCurrentVideoTime),
120
+ onMouseDown: e => {
121
+ handleMouseDown(e, setIsDragging);
122
+ },
123
+ onMouseLeave: () => {
124
+ if (!isDragging) {
125
+ setHoverTime(0);
126
+ }
127
+ },
128
+ onMouseMove: e => handleMouseOver(e, isDragging, duration, progressContainerRef, setHoverTime),
129
+ children: _jsx("div", {
130
+ className: styles.fragmentsContainer,
131
+ children: getProgressBarFragments({
132
+ duration,
133
+ fragments,
134
+ bufferedFragments,
135
+ currentVideoTime
136
+ })
137
+ })
138
+ })]
139
+ });
140
+ };
@@ -0,0 +1,91 @@
1
+ // .progressBarContainer {
2
+ // z-index: 1000;
3
+ // }
4
+
5
+ .progressContainer {
6
+ position: relative;
7
+ width: 100%;
8
+ min-height: 4px;
9
+ height: 4px;
10
+ max-height: 6px;
11
+ cursor: pointer;
12
+ // overflow: hidden;
13
+ border-radius: 0px;
14
+ z-index: 200;
15
+
16
+ &:hover {
17
+ transform: scaleY(1.1);
18
+ }
19
+ }
20
+
21
+ .background {
22
+ position: absolute;
23
+ top: 0;
24
+ left: 0;
25
+ right: 0;
26
+ bottom: 0;
27
+ background-color: #333;
28
+ z-index: 0;
29
+ }
30
+
31
+ .fragment {
32
+ // position: absolute;
33
+ height: 100%;
34
+ top: 0;
35
+ z-index: 1000;
36
+ // pointer-events: none;
37
+ // border-radius: 200px;
38
+ background-repeat: no-repeat;
39
+ background-size: 100% 100%;
40
+
41
+ }
42
+
43
+ .progressTimeHover {
44
+ position: absolute;
45
+ bottom: 100%;
46
+ transform: translateX(-50%);
47
+ background: rgba(0, 0, 0, 0.8);
48
+ color: white;
49
+ padding: 4px 8px;
50
+ border-radius: 4px;
51
+ font-size: 12px;
52
+ white-space: nowrap;
53
+ z-index: 100;
54
+ }
55
+
56
+ .progressTimeHover_hidden {
57
+ display: none;
58
+ }
59
+
60
+ .fragmentsContainer {
61
+ top: 0;
62
+ left: 0;
63
+ height: 100%;
64
+ width: 100%;
65
+ position: relative;
66
+ display: flex;
67
+ flex-direction: row;
68
+ gap: 2px;
69
+ z-index: 100;
70
+
71
+ // &:hover {
72
+ // height: 6px;
73
+ // }
74
+ &:hover {
75
+ transform: scaleY(2);
76
+ }
77
+ }
78
+
79
+ .pointer {
80
+ z-index: 1000;
81
+ position: absolute;
82
+ width: 120px;
83
+ height: 120px;
84
+ border-radius: 50%;
85
+ user-select: none;
86
+ background-color: #ff0000;
87
+ bottom: -5px;
88
+ // right: 0;
89
+ // left: 0;
90
+ transform: translateX(50%);
91
+ }
@@ -0,0 +1,2 @@
1
+ export { SettingsButtons } from './ui/setting-buttons';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entites/settings-buttons/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1 @@
1
+ export { SettingsButtons } from './ui/setting-buttons';
@@ -0,0 +1,9 @@
1
+ import { Dispatch, RefObject, SetStateAction } from "react";
2
+ import { ModalType } from "../models/settings-buttons.interface";
3
+ export declare const handleChangeVideoSpeed: (videoRef: RefObject<HTMLVideoElement>, value: number) => void;
4
+ export declare const openModal: (newTitle: ModalType, setModalHistory: (newModalHistory: ModalType[] | ((prev: ModalType[]) => ModalType[])) => void, setActiveModal: (activeModal: ModalType) => void) => void;
5
+ export declare const closeModal: (modalHistory: ModalType[], setModalHistory: (newModalHistory: ModalType[]) => void, setActiveModal: (activeModal: ModalType) => void) => void;
6
+ export declare const goBack: (modalHistory: ModalType[], setModalHistory: (newModalHistory: ModalType[] | ((prev: ModalType[]) => ModalType[])) => void, setActiveModal: (activeModal: ModalType) => void) => void;
7
+ export declare const handleOpenFullScreen: (setIsFull: Dispatch<SetStateAction<boolean>>) => void;
8
+ export declare const enablePictureInPicture: (videoRef: RefObject<HTMLVideoElement>) => Promise<void>;
9
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../../src/entites/settings-buttons/lib/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,eAAO,MAAM,sBAAsB,GAAI,UAAU,SAAS,CAAC,gBAAgB,CAAC,EAAE,OAAO,MAAM,SAI1F,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,UAAU,SAAS,EAAE,iBAAiB,CAAC,eAAe,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,CAAC,KAAK,IAAI,EAAE,gBAAgB,CAAC,WAAW,EAAE,SAAS,KAAK,IAAI,SAK9L,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,cAAc,SAAS,EAAE,EAAE,iBAAiB,CAAC,eAAe,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE,gBAAgB,CAAC,WAAW,EAAE,SAAS,KAAK,IAAI,SAG9J,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,cAAc,SAAS,EAAE,EAAE,iBAAiB,CAAC,eAAe,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,CAAC,KAAK,IAAI,EAAE,gBAAgB,CAAC,WAAW,EAAE,SAAS,KAAK,IAAI,SAMjM,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,WAAW,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,SAYhF,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAS,UAAU,SAAS,CAAC,gBAAgB,CAAC,kBAQhF,CAAA"}
@@ -0,0 +1,42 @@
1
+ export const handleChangeVideoSpeed = (videoRef, value) => {
2
+ if (!videoRef || !videoRef.current) return;
3
+ videoRef.current.playbackRate = value;
4
+ };
5
+ export const openModal = (newTitle, setModalHistory, setActiveModal) => {
6
+ if (newTitle) {
7
+ setModalHistory(prev => [...prev, newTitle]);
8
+ setActiveModal(newTitle);
9
+ }
10
+ };
11
+ export const closeModal = (modalHistory, setModalHistory, setActiveModal) => {
12
+ setModalHistory([]);
13
+ setActiveModal(null);
14
+ };
15
+ export const goBack = (modalHistory, setModalHistory, setActiveModal) => {
16
+ if (modalHistory.length > 0) {
17
+ const previousModal = modalHistory[modalHistory.length - 2];
18
+ setModalHistory(prev => prev.slice(0, -1));
19
+ setActiveModal(previousModal);
20
+ }
21
+ };
22
+ export const handleOpenFullScreen = setIsFull => {
23
+ const playerContainer = document.getElementById('playerContainer');
24
+ setIsFull(prev => {
25
+ if (prev) {
26
+ document?.exitFullscreen();
27
+ return false;
28
+ } else {
29
+ playerContainer?.requestFullscreen();
30
+ return true;
31
+ }
32
+ });
33
+ };
34
+ export const enablePictureInPicture = async videoRef => {
35
+ if (document.pictureInPictureEnabled) {
36
+ try {
37
+ await videoRef.current.requestPictureInPicture();
38
+ } catch (error) {
39
+ console.error(error);
40
+ }
41
+ }
42
+ };
@@ -0,0 +1,6 @@
1
+ import { RefObject } from "react";
2
+ export interface ISettingsButtons {
3
+ videoRef: RefObject<HTMLVideoElement>;
4
+ }
5
+ export type ModalType = 'settings' | 'quality' | 'speed' | null;
6
+ //# sourceMappingURL=settings-buttons.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-buttons.interface.d.ts","sourceRoot":"","sources":["../../../../src/entites/settings-buttons/models/settings-buttons.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;CACzC;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ISettingsButtons } from '../models/settings-buttons.interface';
2
+ export declare const SettingsButtons: React.FC<ISettingsButtons>;
3
+ //# sourceMappingURL=setting-buttons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setting-buttons.d.ts","sourceRoot":"","sources":["../../../../src/entites/settings-buttons/ui/setting-buttons.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAa,MAAM,sCAAsC,CAAA;AAMlF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA4HtD,CAAA"}