@desynova-digital/player 4.0.43 → 4.0.44
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.
|
@@ -118,14 +118,18 @@ var SeekBar = exports["default"] = /*#__PURE__*/function (_Component) {
|
|
|
118
118
|
var distance = this.slider.calculateDistance(event);
|
|
119
119
|
newTime = distance * duration;
|
|
120
120
|
} else {
|
|
121
|
-
var seekBar =
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
var seekBar = event.currentTarget || event.target.closest('#timeline-block');
|
|
122
|
+
if (!seekBar) {
|
|
123
|
+
console.warn('Seekbar element not found.');
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
var rect = seekBar.getBoundingClientRect();
|
|
127
|
+
var clickPosition = event.clientX - rect.left;
|
|
128
|
+
// Optional improvement: getScrollableWidth could be replaced with rect.width if that's what it returns.
|
|
129
|
+
var totalWidth = typeof this.getScrollableWidth === 'function' ? this.getScrollableWidth(seekBar) : rect.width;
|
|
130
|
+
var seekPercentage = clickPosition / totalWidth;
|
|
125
131
|
newTime = duration * seekPercentage;
|
|
126
132
|
}
|
|
127
|
-
|
|
128
|
-
// Don't let video end while scrubbing.
|
|
129
133
|
return newTime === duration ? newTime - 0.1 : newTime;
|
|
130
134
|
}
|
|
131
135
|
}, {
|
|
@@ -33,9 +33,7 @@ var propTypes = {
|
|
|
33
33
|
initialTime: _propTypes.PropTypes.number,
|
|
34
34
|
frameRate: _propTypes.PropTypes.number
|
|
35
35
|
};
|
|
36
|
-
var TimelineBlock = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n
|
|
37
|
-
return props.maxWidth ? props.maxWidth : '';
|
|
38
|
-
}, _components.Icon.Element, _components.Icon.Element);
|
|
36
|
+
var TimelineBlock = _styledComponents["default"].div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n align-items: stretch;\n width: 100%;\n height: 46px;\n position: relative;\n box-sizing: border-box;\n overflow: hidden;\n\n .player-time {\n flex: 0 0 auto;\n width: 100px;\n height: 100%;\n position: relative;\n user-select: none;\n\n &:first-child p {\n left: 0;\n }\n\n &:last-child {\n flex-grow: 1;\n ", " {\n display: none;\n }\n p {\n left: auto;\n right: 0;\n }\n }\n\n ", " {\n position: absolute;\n left: 0;\n bottom: 0;\n }\n\n p {\n position: absolute;\n font-size: 10px;\n font-family: SFUIText-Regular;\n color: #aaa;\n top: 10px;\n left: -28px;\n letter-spacing: 0.5px;\n }\n }\n"])), _components.Icon.Element, _components.Icon.Element);
|
|
39
37
|
var Timeline = exports["default"] = /*#__PURE__*/function (_Component) {
|
|
40
38
|
function Timeline(props, context) {
|
|
41
39
|
var _this;
|
|
@@ -65,31 +63,32 @@ var Timeline = exports["default"] = /*#__PURE__*/function (_Component) {
|
|
|
65
63
|
key: "generateTimeline",
|
|
66
64
|
value: function generateTimeline(zoomFactor) {
|
|
67
65
|
var player = this.props.player;
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
66
|
+
var seekbar = document.getElementById('seekbar-control-block');
|
|
67
|
+
if (!seekbar) return;
|
|
68
|
+
var baseBlockWidth = 100;
|
|
69
|
+
var sliderWidth;
|
|
70
|
+
|
|
71
|
+
// Calculate slider width based on zoom
|
|
72
|
+
var baseWidth = seekbar.clientWidth;
|
|
73
|
+
sliderWidth = zoomFactor > 0 ? Math.round(baseWidth * zoomFactor * 20) : Math.round(baseWidth);
|
|
74
|
+
|
|
75
|
+
// Calculate how many full blocks of 100px fit, and the leftover width
|
|
76
|
+
var noOfBlocks = Math.floor(sliderWidth / baseBlockWidth);
|
|
77
|
+
|
|
78
|
+
// Compute time distance between ticks
|
|
79
|
+
var totalDuration = player.duration; // e.g., 20s
|
|
80
|
+
var timeDistance = totalDuration / noOfBlocks;
|
|
81
|
+
|
|
82
|
+
// Create time array
|
|
83
|
+
var timeArray = [];
|
|
84
|
+
for (var i = 0; i <= noOfBlocks; i++) {
|
|
85
|
+
var timePoint = parseFloat((i * timeDistance).toFixed(2));
|
|
86
|
+
timeArray.push(Math.min(timePoint, totalDuration));
|
|
88
87
|
}
|
|
89
88
|
this.setState({
|
|
90
89
|
timeArray: timeArray,
|
|
91
90
|
zoom: zoomFactor,
|
|
92
|
-
maxWidth: sliderWidth
|
|
91
|
+
maxWidth: "".concat(sliderWidth, "px")
|
|
93
92
|
});
|
|
94
93
|
}
|
|
95
94
|
}, {
|
|
@@ -98,7 +97,8 @@ var Timeline = exports["default"] = /*#__PURE__*/function (_Component) {
|
|
|
98
97
|
var _this2 = this;
|
|
99
98
|
var _this$props2 = this.props,
|
|
100
99
|
initialTime = _this$props2.initialTime,
|
|
101
|
-
frameRate = _this$props2.frameRate
|
|
100
|
+
frameRate = _this$props2.frameRate,
|
|
101
|
+
player = _this$props2.player;
|
|
102
102
|
var _this$state = this.state,
|
|
103
103
|
timeArray = _this$state.timeArray,
|
|
104
104
|
maxWidth = _this$state.maxWidth;
|
|
@@ -110,11 +110,14 @@ var Timeline = exports["default"] = /*#__PURE__*/function (_Component) {
|
|
|
110
110
|
}
|
|
111
111
|
}, timeArray.map(function (time) {
|
|
112
112
|
var formattedTime = (0, _utils.secondsToTime)(time, frameRate, initialTime);
|
|
113
|
+
var leftPercent = time / player.duration * 100;
|
|
113
114
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
114
115
|
className: "player-time",
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
style: {
|
|
117
|
+
position: 'absolute',
|
|
118
|
+
left: "".concat(leftPercent, "%")
|
|
119
|
+
} // Fix marker alignment
|
|
120
|
+
,
|
|
118
121
|
key: time
|
|
119
122
|
}, /*#__PURE__*/_react["default"].createElement("p", null, formattedTime), /*#__PURE__*/_react["default"].createElement(_components.Icon, {
|
|
120
123
|
name: "timeline",
|