@appquality/unguess-design-system 3.1.40-player → 3.1.41-player
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/build/index.js +10 -11
- package/build/stories/player/_types.d.ts +2 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -4420,22 +4420,22 @@ const Controls = ({ container, }) => {
|
|
|
4420
4420
|
const [tooltipLabel, setTooltipLabel] = React.useState("00:00");
|
|
4421
4421
|
const progressRef = React.useRef(null);
|
|
4422
4422
|
const { context, setCurrentTime } = Video.useVideoContext();
|
|
4423
|
+
const relCurrentTime = (((_a = context.player) === null || _a === void 0 ? void 0 : _a.currentTime) || 0) - context.part.start;
|
|
4424
|
+
const duration = context.part.end - context.part.start || ((_b = context.player) === null || _b === void 0 ? void 0 : _b.totalTime) || 0; //relative
|
|
4423
4425
|
const getVideoPositionFromEvent = (clientX) => {
|
|
4424
|
-
|
|
4425
|
-
const totalTime = ((_a = context.player) === null || _a === void 0 ? void 0 : _a.totalTime) || 0;
|
|
4426
|
-
if (progressRef && progressRef.current && totalTime) {
|
|
4426
|
+
if (progressRef && progressRef.current && duration) {
|
|
4427
4427
|
const bounds = progressRef.current.getBoundingClientRect();
|
|
4428
4428
|
const x = clientX - bounds.left;
|
|
4429
|
-
const videoPositionSecs = (x / progressRef.current.clientWidth) *
|
|
4429
|
+
const videoPositionSecs = (x / progressRef.current.clientWidth) * duration;
|
|
4430
4430
|
return videoPositionSecs;
|
|
4431
4431
|
}
|
|
4432
4432
|
return 0;
|
|
4433
4433
|
};
|
|
4434
4434
|
const handleSkipAhead = React.useCallback((pageX) => {
|
|
4435
|
-
const time = getVideoPositionFromEvent(pageX);
|
|
4435
|
+
const time = getVideoPositionFromEvent(pageX) + (context.part.start || 0);
|
|
4436
4436
|
setCurrentTime(time);
|
|
4437
4437
|
setProgress(getProgress(time));
|
|
4438
|
-
}, [context.player]);
|
|
4438
|
+
}, [context.player, context.part]);
|
|
4439
4439
|
const onMouseEvent = (e) => {
|
|
4440
4440
|
if (progressRef && progressRef.current) {
|
|
4441
4441
|
const tooltipWidth = 40;
|
|
@@ -4454,13 +4454,12 @@ const Controls = ({ container, }) => {
|
|
|
4454
4454
|
setProgress(getProgress(currentTime));
|
|
4455
4455
|
}, [context.player]);
|
|
4456
4456
|
const getProgress = React.useCallback((currentTime) => {
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
if (totalTime === 0)
|
|
4457
|
+
const current = currentTime - (context.part.start || 0);
|
|
4458
|
+
if (duration === 0)
|
|
4460
4459
|
return 0;
|
|
4461
|
-
return (
|
|
4460
|
+
return (current / duration) * 100;
|
|
4462
4461
|
}, [context.player]);
|
|
4463
|
-
return (jsxRuntime.jsxs(ControlsWrapper, Object.assign({ isPlaying: context.isPlaying }, { children: [jsxRuntime.jsxs(ProgressContainer, Object.assign({ onMouseEnter: onMouseEvent, onMouseMove: onMouseEvent, onMouseLeave: onMouseEvent }, { children: [jsxRuntime.jsx(StyledTooltip, Object.assign({ style: { marginLeft: `${tooltipMargin}px` } }, { children: tooltipLabel })), jsxRuntime.jsx(TimeLabel, { current: formatDuration(
|
|
4462
|
+
return (jsxRuntime.jsxs(ControlsWrapper, Object.assign({ isPlaying: context.isPlaying }, { children: [jsxRuntime.jsxs(ProgressContainer, Object.assign({ onMouseEnter: onMouseEvent, onMouseMove: onMouseEvent, onMouseLeave: onMouseEvent }, { children: [jsxRuntime.jsx(StyledTooltip, Object.assign({ style: { marginLeft: `${tooltipMargin}px` } }, { children: tooltipLabel })), jsxRuntime.jsx(TimeLabel, { current: formatDuration(relCurrentTime), duration: formatDuration(duration) }), jsxRuntime.jsx(StyledProgress, { ref: progressRef, value: progress, onClick: (e) => handleSkipAhead(e.clientX) })] })), jsxRuntime.jsxs(ControlsBar, { children: [jsxRuntime.jsx(StyledDiv$2, { children: jsxRuntime.jsx(AudioButton, {}) }), jsxRuntime.jsx(ControlsGroupCenter, {}), jsxRuntime.jsx(StyledDiv$2, { children: jsxRuntime.jsx(FullScreenButton, { container: container }) })] })] })));
|
|
4464
4463
|
};
|
|
4465
4464
|
|
|
4466
4465
|
var _path$7;
|