@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,173 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useState } from 'react';
4
+ import { usePlayerContext } from '../../../component';
5
+ import { closeModal, enablePictureInPicture, goBack, handleChangeVideoSpeed, handleOpenFullScreen, openModal } from '../lib/handlers';
6
+ import { Svg } from '../../../shared/ui';
7
+ import styles from './styles.module.scss';
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ export const SettingsButtons = ({
10
+ videoRef
11
+ }) => {
12
+ const [isFull, setIsFull] = useState(false);
13
+ const [activeModal, setActiveModal] = useState(null);
14
+ const [modalHistory, setModalHistory] = useState([]);
15
+ const context = usePlayerContext();
16
+ useEffect(() => {
17
+ const handleClickOutSide = e => {
18
+ const modal = document.getElementById('settingsWrapper');
19
+ if (!modal?.contains(e.target)) {
20
+ closeModal(modalHistory, setModalHistory, setActiveModal);
21
+ }
22
+ };
23
+ window.addEventListener('mousedown', handleClickOutSide);
24
+ return () => {
25
+ window.removeEventListener('mousedown', handleClickOutSide);
26
+ };
27
+ }, [videoRef]);
28
+ useEffect(() => {
29
+ const handlePressFtoFullScreen = e => {
30
+ if (e.key.toLowerCase() === 'f') {
31
+ console.log('F');
32
+ handleOpenFullScreen(setIsFull);
33
+ }
34
+ };
35
+ document.addEventListener('keyup', handlePressFtoFullScreen);
36
+ return () => {
37
+ document.removeEventListener('keyup', handlePressFtoFullScreen);
38
+ };
39
+ }, []);
40
+ const handleSpeed = value => {
41
+ handleChangeVideoSpeed(videoRef, value);
42
+ closeModal(modalHistory, setModalHistory, setActiveModal);
43
+ };
44
+ const handleChangeQualityLevel = newQualityLevel => {
45
+ context.hls.currentLevel = newQualityLevel;
46
+ closeModal(modalHistory, setModalHistory, setActiveModal);
47
+ };
48
+ return _jsxs("div", {
49
+ className: styles.settingsContainer,
50
+ children: [_jsx("button", {
51
+ className: styles.subtitle,
52
+ onClick: e => context.hls.subtitleDisplay ? context.hls.subtitleDisplay = false : context.hls.subtitleDisplay = true,
53
+ children: _jsx("div", {
54
+ className: styles.btnWrap,
55
+ children: _jsx(Svg, {
56
+ name: "subtitle"
57
+ })
58
+ })
59
+ }), _jsx("button", {
60
+ className: styles.subtitle,
61
+ onClick: e => enablePictureInPicture(videoRef),
62
+ children: _jsx("div", {
63
+ className: styles.btnWrap,
64
+ children: _jsx(Svg, {
65
+ name: "pictureInPicture"
66
+ })
67
+ })
68
+ }), _jsxs("div", {
69
+ id: "settingsWrapper",
70
+ className: styles.settingsWrapper,
71
+ children: [_jsx("button", {
72
+ className: styles.settings,
73
+ onClick: () => openModal('settings', setModalHistory, setActiveModal),
74
+ children: _jsx("div", {
75
+ className: styles.btnWrapSettings,
76
+ children: _jsx(Svg, {
77
+ name: "settings"
78
+ })
79
+ })
80
+ }), activeModal === 'settings' && _jsxs("div", {
81
+ className: styles.modal,
82
+ children: [_jsx("button", {
83
+ className: styles.modalBtn,
84
+ onClick: () => openModal('quality', setModalHistory, setActiveModal),
85
+ children: _jsxs("div", {
86
+ className: styles.modalBtnContainer,
87
+ children: [_jsx("div", {
88
+ children: "\u041A\u0430\u0447\u0435\u0441\u0442\u0432\u043E"
89
+ }), _jsx("div", {
90
+ children: `${context.hls.levels[context.hls.currentLevel]?.height}p`
91
+ })]
92
+ })
93
+ }), _jsx("button", {
94
+ className: styles.modalBtn,
95
+ onClick: () => openModal('speed', setModalHistory, setActiveModal),
96
+ children: _jsxs("div", {
97
+ className: styles.modalBtnContainer,
98
+ children: [_jsx("div", {
99
+ className: styles.speedLabel,
100
+ children: "\u0421\u043A\u043E\u0440\u043E\u0441\u0442\u044C \u0432\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0434\u0435\u043D\u0438\u044F"
101
+ }), _jsxs("div", {
102
+ className: styles.speedValue,
103
+ children: [videoRef.current.playbackRate, "x"]
104
+ })]
105
+ })
106
+ })]
107
+ }), activeModal === 'quality' && _jsxs("div", {
108
+ className: styles.modal,
109
+ onClick: () => goBack(modalHistory, setModalHistory, setActiveModal),
110
+ children: [_jsxs("h3", {
111
+ className: styles.modalHeader,
112
+ children: ['<', " \u041A\u0430\u0447\u0435\u0441\u0442\u0432\u043E"]
113
+ }), context.hls.levels.map((level, index) => {
114
+ return _jsxs("button", {
115
+ className: styles.modalBtn,
116
+ onClick: () => handleChangeQualityLevel(index),
117
+ children: [level?.height, "p"]
118
+ }, index);
119
+ })]
120
+ }), activeModal === 'speed' && _jsxs("div", {
121
+ className: styles.modal,
122
+ onClick: () => goBack(modalHistory, setModalHistory, setActiveModal),
123
+ children: [_jsxs("h3", {
124
+ className: styles.modalHeader,
125
+ children: ['<', " \u0421\u043A\u043E\u0440\u043E\u0441\u0442\u044C \u0432\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0434\u0435\u043D\u0438\u044F"]
126
+ }), _jsx("button", {
127
+ className: styles.modalBtn,
128
+ onClick: () => handleSpeed(0.25),
129
+ children: "0.25x"
130
+ }), _jsx("button", {
131
+ className: styles.modalBtn,
132
+ onClick: () => handleSpeed(0.5),
133
+ children: "0.5x"
134
+ }), _jsx("button", {
135
+ className: styles.modalBtn,
136
+ onClick: () => handleSpeed(0.75),
137
+ children: "0.75x"
138
+ }), _jsx("button", {
139
+ className: styles.modalBtn,
140
+ onClick: () => handleSpeed(1),
141
+ children: "1x"
142
+ }), _jsx("button", {
143
+ className: styles.modalBtn,
144
+ onClick: () => handleSpeed(1.25),
145
+ children: "1.25x"
146
+ }), _jsx("button", {
147
+ className: styles.modalBtn,
148
+ onClick: () => handleSpeed(1.5),
149
+ children: "1.5x"
150
+ }), _jsx("button", {
151
+ className: styles.modalBtn,
152
+ onClick: () => handleSpeed(1.75),
153
+ children: "1.75x"
154
+ }), _jsx("button", {
155
+ className: styles.modalBtn,
156
+ onClick: () => handleSpeed(2),
157
+ children: "2x"
158
+ })]
159
+ })]
160
+ }), _jsx("button", {
161
+ className: styles.subtitle,
162
+ onClick: e => handleOpenFullScreen(setIsFull),
163
+ children: _jsx("div", {
164
+ className: styles.btnWrap,
165
+ children: isFull ? _jsx(Svg, {
166
+ name: "fullScreenOff"
167
+ }) : _jsx(Svg, {
168
+ name: "fullScreenOn"
169
+ })
170
+ })
171
+ })]
172
+ });
173
+ };
@@ -0,0 +1,135 @@
1
+ .settingsContainer {
2
+ display: flex;
3
+ gap: 10px;
4
+ // position: absolute;
5
+ bottom: 0;
6
+ height: 90%;
7
+ right: 3%;
8
+ z-index: 500;
9
+ display: flex;
10
+ align-items: center;
11
+ }
12
+
13
+ .settingsOptions {
14
+ display: block;
15
+ position: absolute;
16
+ // bottom: 200%;
17
+ background-color: aqua;
18
+ display: flex;
19
+ flex-direction: column;
20
+ // gap: 10px;
21
+ }
22
+
23
+ .settingsWrapper {
24
+ background-color: rgb(0, 0, 0, 0.3);
25
+ user-select: none;
26
+ // pointer-events: none;
27
+ cursor: pointer;
28
+ transition: all 0.2s ease;
29
+ border-radius: 28px;
30
+ padding: 0px 0px 0px 0px;
31
+ }
32
+
33
+ .settingOption {
34
+ background-color: aqua;
35
+ padding: 10px 20px;
36
+ &:hover {
37
+ background-color: #fff;
38
+ }
39
+ }
40
+
41
+ .subtitle {
42
+ background-color: rgb(0, 0, 0, 0.3);
43
+ color: #fff;
44
+ user-select: none;
45
+ border: none;
46
+ cursor: pointer;
47
+ transition: all 0.2s ease;
48
+ border-radius: 28px;
49
+ padding: 3px 4px 3px 4px;
50
+ }
51
+
52
+ .btnWrap {
53
+ border-radius: 28px;
54
+ padding: 3px 4px 3px 4px;
55
+ border: none;
56
+
57
+ &Settings {
58
+ border-radius: 28px;
59
+ border: none;
60
+ padding: 5px 4px 1px 4px;
61
+
62
+ &:hover {
63
+ background-color: rgb(255, 255, 255, 0.1);
64
+ }
65
+ }
66
+
67
+ &:hover {
68
+ background-color: rgb(255, 255, 255, 0.1);
69
+ }
70
+ }
71
+
72
+ .settings {
73
+ border-radius: 28px;
74
+ padding: 3px 4px 3px 4px;
75
+ color: #ffffff;
76
+ background: none;
77
+ cursor: pointer;
78
+ border: none;
79
+ user-select: none;
80
+ }
81
+
82
+ .modalHeader {
83
+ cursor: pointer;
84
+ color: #fff;
85
+ font-family: 'Roboto';
86
+ font-weight: 400;
87
+ font-size: 14px;
88
+ }
89
+
90
+ .modalBtn {
91
+ background: none;
92
+ padding: 10 5;
93
+ color: #fff;
94
+ border: none;
95
+ font-size: 20px;
96
+ font-family: 'Roboto';
97
+ font-weight: 400;
98
+ font-size: 14px;
99
+
100
+ &:hover {
101
+ background-color: rgb(255, 231, 201, 0.1);
102
+ border-radius: 10px;
103
+ }
104
+ }
105
+
106
+ .modalBtnContainer {
107
+ width: 100%;
108
+ display: flex;
109
+ justify-content: space-between;
110
+ }
111
+
112
+ .modal {
113
+ width: 400px;
114
+ position: absolute;
115
+ transform: translateX(-45%);
116
+ bottom: 80px;
117
+ background-color: rgb(38, 41, 41, 0.7);
118
+ padding: 10px;
119
+ right: -12%;
120
+ display: flex;
121
+ flex-direction: column;
122
+ }
123
+
124
+ .fullScreen {
125
+ background: none;
126
+ border: none;
127
+ user-select: none;
128
+ }
129
+
130
+ .fullScreenImg {
131
+ height: 24px;
132
+ &:hover {
133
+ // transform: scale(1.1);
134
+ }
135
+ }
@@ -0,0 +1,2 @@
1
+ export { SoundAndTimeVolume } from './ui/sound-volume';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entites/sound-volume/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1 @@
1
+ export { SoundAndTimeVolume } from './ui/sound-volume';
@@ -0,0 +1,6 @@
1
+ import { RefObject } from "react";
2
+ export declare const handleMuteOnClick: (videoRef: RefObject<HTMLVideoElement | null>, setCurrentVolume: (volume: number) => void) => void;
3
+ export declare const handleMouseClickSoundBtn: (e: React.MouseEvent, videoRef: RefObject<HTMLVideoElement | null>, setCurrentVolume: (volume: number) => void) => void;
4
+ export declare const handleMouseDownSoundBtn: (setIsDraggingVolume: (isDragging: boolean) => void) => void;
5
+ export declare const handleMouseUpSoundBtn: (setIsDraggingVolume: (isDragging: boolean) => void) => void;
6
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../../src/entites/sound-volume/lib/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGjC,eAAO,MAAM,iBAAiB,GAC1B,UAAU,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAC5C,kBAAkB,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,SAY7C,CAAA;AAGD,eAAO,MAAM,wBAAwB,GACjC,GAAG,KAAK,CAAC,UAAU,EACnB,UAAU,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAC5C,kBAAkB,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,SAa7C,CAAA;AAGD,eAAO,MAAM,uBAAuB,GAChC,qBAAqB,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,SAGrD,CAAA;AAGD,eAAO,MAAM,qBAAqB,GAC9B,qBAAqB,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,SAGrD,CAAA"}
@@ -0,0 +1,27 @@
1
+ export const handleMuteOnClick = (videoRef, setCurrentVolume) => {
2
+ if (!videoRef.current) return;
3
+ if (videoRef.current.muted || videoRef.current.volume === 0) {
4
+ videoRef.current.muted = false;
5
+ videoRef.current.volume = 0.5;
6
+ setCurrentVolume(50);
7
+ } else {
8
+ videoRef.current.muted = true;
9
+ setCurrentVolume(0);
10
+ }
11
+ };
12
+ export const handleMouseClickSoundBtn = (e, videoRef, setCurrentVolume) => {
13
+ const soundVolumeBackgroundBar = document.getElementById('soundVolumeBackground');
14
+ if (!soundVolumeBackgroundBar || !videoRef.current) return;
15
+ const positionOfSoundBar = soundVolumeBackgroundBar.getBoundingClientRect();
16
+ const positionOfNewVolume = (e.clientX - positionOfSoundBar.left) / positionOfSoundBar.width;
17
+ const newVolume = Math.max(0, Math.min(1, positionOfNewVolume));
18
+ console.log(newVolume);
19
+ videoRef.current.volume = newVolume;
20
+ setCurrentVolume(newVolume * 100);
21
+ };
22
+ export const handleMouseDownSoundBtn = setIsDraggingVolume => {
23
+ setIsDraggingVolume(true);
24
+ };
25
+ export const handleMouseUpSoundBtn = setIsDraggingVolume => {
26
+ setIsDraggingVolume(false);
27
+ };
@@ -0,0 +1,9 @@
1
+ import React, { RefObject } from 'react';
2
+ interface ISoundVolume {
3
+ videoRef: RefObject<HTMLVideoElement | null>;
4
+ duration: number;
5
+ fragmentTitle: string | undefined;
6
+ }
7
+ export declare const SoundAndTimeVolume: React.FC<ISoundVolume>;
8
+ export {};
9
+ //# sourceMappingURL=sound-volume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sound-volume.d.ts","sourceRoot":"","sources":["../../../../src/entites/sound-volume/ui/sound-volume.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAA;AAiB7D,UAAU,YAAY;IAClB,QAAQ,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAA;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAyHrD,CAAA"}
@@ -0,0 +1,113 @@
1
+ "use client";
2
+
3
+ import React, { useEffect, useState } from 'react';
4
+ import { getHHSStime } from '../../../shared/utils/getHHSStime';
5
+ import { handleMouseClickSoundBtn, handleMouseDownSoundBtn, handleMouseUpSoundBtn, handleMuteOnClick } from '../lib/handlers';
6
+ import { Svg } from '../../../shared/ui';
7
+ import { usePlayerContext } from '../../../component';
8
+ import styles from './styles.module.scss';
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ export const SoundAndTimeVolume = ({
11
+ videoRef,
12
+ duration,
13
+ fragmentTitle
14
+ }) => {
15
+ const [isVisibleSoundBar, setIsVisibleSoundBar] = useState(false);
16
+ const [currentVolume, setCurrentVolume] = useState(50);
17
+ const [isDraggingVolume, setIsDraggingVolume] = useState(false);
18
+ const [currentTime, setCurrentTime] = useState(0);
19
+ const context = usePlayerContext();
20
+ useEffect(() => {
21
+ if (!videoRef.current) return;
22
+ const video = videoRef.current;
23
+ const handleTimeUpdate = () => {
24
+ setCurrentTime(video.currentTime);
25
+ };
26
+ video.addEventListener('timeupdate', handleTimeUpdate);
27
+ setCurrentTime(video.currentTime);
28
+ return () => {
29
+ video.removeEventListener('timeupdate', handleTimeUpdate);
30
+ };
31
+ }, [videoRef]);
32
+ useEffect(() => {
33
+ const handleGlobalMouseUp = () => {
34
+ if (isDraggingVolume) {
35
+ setIsDraggingVolume(false);
36
+ }
37
+ };
38
+ const handleGlobalMouseMove = e => {
39
+ if (isDraggingVolume && videoRef.current) {
40
+ const soundVolumeBackgroundBar = document.getElementById('soundVolumeBackground');
41
+ if (!soundVolumeBackgroundBar) return;
42
+ const positionOfSoundBar = soundVolumeBackgroundBar.getBoundingClientRect();
43
+ let newCurrentVolume = (e.clientX - positionOfSoundBar.left) / positionOfSoundBar.width * 100;
44
+ newCurrentVolume = Math.max(0, Math.min(100, newCurrentVolume));
45
+ setCurrentVolume(newCurrentVolume);
46
+ videoRef.current.volume = newCurrentVolume / 100;
47
+ }
48
+ };
49
+ window.addEventListener('mouseup', handleGlobalMouseUp);
50
+ window.addEventListener('mousemove', handleGlobalMouseMove);
51
+ return () => {
52
+ window.removeEventListener('mouseup', handleGlobalMouseUp);
53
+ window.removeEventListener('mousemove', handleGlobalMouseMove);
54
+ };
55
+ }, [isDraggingVolume, videoRef]);
56
+ if (!videoRef.current) return null;
57
+ return _jsxs("div", {
58
+ className: styles.soundAndTimeContainer,
59
+ children: [_jsxs("div", {
60
+ className: styles.soundContainer,
61
+ onMouseEnter: () => setIsVisibleSoundBar(true),
62
+ onMouseLeave: () => {
63
+ if (!isDraggingVolume) {
64
+ setIsVisibleSoundBar(false);
65
+ }
66
+ },
67
+ children: [_jsx("div", {
68
+ className: styles.soundBtnWrapper,
69
+ children: _jsx("button", {
70
+ className: styles.soundBtn,
71
+ onClick: () => handleMuteOnClick(videoRef, setCurrentVolume),
72
+ children: currentVolume ? _jsx(Svg, {
73
+ name: "soundOn"
74
+ }) : _jsx(Svg, {
75
+ name: "soundOff"
76
+ })
77
+ })
78
+ }), _jsx("div", {
79
+ id: "soundVolumeBackground",
80
+ className: styles.soundVolumeBackground,
81
+ onClick: e => handleMouseClickSoundBtn(e, videoRef, setCurrentVolume),
82
+ onMouseDown: e => handleMouseDownSoundBtn(setIsDraggingVolume),
83
+ children: _jsx("div", {
84
+ id: "filledSoundBar",
85
+ className: styles.soundVolumeFilled,
86
+ style: {
87
+ width: `${currentVolume}%`
88
+ },
89
+ children: _jsx("div", {
90
+ className: styles.pointer,
91
+ onMouseDown: e => {
92
+ e.stopPropagation();
93
+ handleMouseDownSoundBtn(setIsDraggingVolume);
94
+ },
95
+ onMouseUp: e => {
96
+ e.stopPropagation();
97
+ handleMouseUpSoundBtn(setIsDraggingVolume);
98
+ }
99
+ })
100
+ })
101
+ })]
102
+ }), _jsx("div", {
103
+ className: styles.indicateTimeWrapper,
104
+ children: _jsxs("div", {
105
+ className: styles.indicateTime,
106
+ children: [getHHSStime(Math.trunc(currentTime)), " / ", getHHSStime(Math.trunc(duration))]
107
+ })
108
+ }), _jsx("div", {
109
+ className: styles.fragmentTitle,
110
+ children: fragmentTitle
111
+ })]
112
+ });
113
+ };
@@ -0,0 +1,124 @@
1
+ .soundAndTimeContainer {
2
+ width: 65%;
3
+ height: 100%;
4
+ // position: absolute;
5
+ // top: 50%;
6
+ // left: 13%;
7
+ border: none;
8
+ outline: none;
9
+ cursor: pointer;
10
+ display: flex;
11
+ gap: 15px;
12
+ flex-direction: row;
13
+ z-index: 100;
14
+ align-items: center;
15
+ }
16
+
17
+ .soundContainer {
18
+ cursor: pointer;
19
+ display: flex;
20
+ gap: 15px;
21
+ align-items: center;
22
+ }
23
+
24
+ .soundBtnWrapper {
25
+ background-color: rgb(0, 0, 0, 0.3);
26
+ user-select: none;
27
+ border: none;
28
+ cursor: pointer;
29
+ transition: all 0.2s ease;
30
+ border-radius: 28px;
31
+ padding: 3px 3px 3px 3px;
32
+ }
33
+
34
+ .soundBtn {
35
+ background-color: rgb(0, 0, 0, 0.0);
36
+ user-select: none;
37
+ border: none;
38
+ transition: all 0.2s ease;
39
+ border-radius: 28px;
40
+ padding: 2px 6px 2px 6px;
41
+
42
+ &:hover {
43
+ background-color: rgb(255, 255, 255, 0.1);
44
+ }
45
+ }
46
+
47
+ .soundVolumeBackground {
48
+ width: 80px;
49
+ height: 3px;
50
+ background-color: rgb(255, 255, 255, 0.3);
51
+
52
+ // display: block;
53
+ position: relative;
54
+ transition: width 0.5s ease;
55
+
56
+ &_hidden {
57
+ width: 0%;
58
+ }
59
+ }
60
+
61
+ .soundVolumeFilled {
62
+ height: 3px;
63
+ background-color: rgb(255, 255, 255);
64
+ position: relative;
65
+ }
66
+
67
+ .pointer {
68
+ position: absolute;
69
+ width: 12px;
70
+ height: 12px;
71
+ border-radius: 50%;
72
+ user-select: none;
73
+ background-color: #ffffff;
74
+ bottom: -5px;
75
+ right: 0;
76
+ transform: translateX(50%);
77
+ }
78
+
79
+ .indicateTimeWrapper {
80
+ background-color: rgb(0, 0, 0, 0.3);
81
+ user-select: none;
82
+ border: none;
83
+ cursor: pointer;
84
+ transition: all 0.2s ease;
85
+ border-radius: 28px;
86
+ padding: 3px 15px 3px 3px;
87
+ min-width: fit-content;
88
+ }
89
+
90
+ .indicateTime {
91
+ color: rgb(255, 255, 255);
92
+ font-size: 20px;
93
+ height: 50%;
94
+ width: 100%;
95
+ font-weight: 600;
96
+ user-select: none;
97
+ border-radius: 28px;
98
+ padding: 2px 6px 2px 6px;
99
+ text-align: center;
100
+ font-family: 'Roboto';
101
+ font-weight: 400;
102
+ font-size: 14px;
103
+
104
+ &:hover {
105
+ background-color: rgb(255, 255, 255, 0.1);
106
+ }
107
+
108
+ &_narrowed {
109
+ font-weight: 600;
110
+ font-size: 20px;
111
+ width: 20%;
112
+ }
113
+ }
114
+
115
+ .fragmentTitle {
116
+ max-width: 600px;
117
+ overflow: hidden;
118
+ text-overflow: ellipsis;
119
+ font-size: 18px;
120
+ color:#ffffff;
121
+ font-family: 'Roboto';
122
+ font-weight: 300;
123
+ white-space: nowrap;
124
+ }
@@ -0,0 +1,3 @@
1
+ import { RefObject } from "react";
2
+ export declare const handlePlayPause: (videoRef: RefObject<HTMLVideoElement | null>) => void;
3
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../../src/features/player-tools/lib/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,eAAO,MAAM,eAAe,GAAI,UAAU,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,SAM3E,CAAA"}
@@ -0,0 +1,7 @@
1
+ export const handlePlayPause = videoRef => {
2
+ if (videoRef.current?.paused) {
3
+ videoRef.current?.play();
4
+ } else {
5
+ videoRef.current?.pause();
6
+ }
7
+ };
@@ -0,0 +1,9 @@
1
+ import { RefObject } from "react";
2
+ import { IFragment } from "../../../widget/video-tag/model/video-tag.interface";
3
+ export interface IPlayerTools {
4
+ duration: number;
5
+ videoRef: RefObject<HTMLVideoElement | null>;
6
+ isVisibleTools: boolean;
7
+ fragments?: IFragment[];
8
+ }
9
+ //# sourceMappingURL=player-tools.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"player-tools.interface.d.ts","sourceRoot":"","sources":["../../../../src/features/player-tools/model/player-tools.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,qDAAqD,CAAC;AAEhF,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAA;IAC5C,cAAc,EAAE,OAAO,CAAA;IACvB,SAAS,CAAC,EAAE,SAAS,EAAE,CAAA;CAC1B"}
@@ -0,0 +1,3 @@
1
+ import { IPlayerTools } from "../model/player-tools.interface";
2
+ export declare const PlayerTools: React.FC<IPlayerTools>;
3
+ //# sourceMappingURL=player-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"player-tools.d.ts","sourceRoot":"","sources":["../../../../src/features/player-tools/ui/player-tools.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAK/D,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAuC9C,CAAC"}