pixuireactcomponents 1.5.29 → 1.5.31
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/package.json
CHANGED
|
@@ -88,12 +88,14 @@ var videoLog = function () {
|
|
|
88
88
|
};
|
|
89
89
|
export var VideoPlayer = function (props) {
|
|
90
90
|
var rootId = props.rootId, rootClassName = props.rootClassName, _a = props.playUrl, playUrl = _a === void 0 ? '' : _a, _b = props.autoPlay, autoPlay = _b === void 0 ? true : _b, playEvent = props.playEvent, iconElement = props.iconElement, _c = props.hideSliderDuration, hideSliderDuration = _c === void 0 ? 3000 : _c, sliderElement = props.sliderElement, videoDuration = props.videoDuration, compRef = props.compRef;
|
|
91
|
-
var isStreaming = !playUrl.endsWith('.mp4');
|
|
91
|
+
var isStreaming = !playUrl.split('?')[0].endsWith('.mp4');
|
|
92
92
|
var refVideo = useRef(null);
|
|
93
93
|
var _d = useState(VideoStatus.Loading), videoStatus = _d[0], setVideoStatus = _d[1];
|
|
94
94
|
var _e = useState(0), currentTime = _e[0], setCurrentTime = _e[1];
|
|
95
95
|
var _f = useState(0), totalTime = _f[0], setTotalTime = _f[1];
|
|
96
96
|
var _g = useState(false), showSlider = _g[0], setShowSlider = _g[1];
|
|
97
|
+
var _h = useState(1.0), currentVolume = _h[0], setCurrentVolume = _h[1]; //视频音量范围0.0~1.0
|
|
98
|
+
var _j = useState(false), isMuted = _j[0], setIsMuted = _j[1];
|
|
97
99
|
var sliderTimmer = useRef(null);
|
|
98
100
|
var rootRef = useRef();
|
|
99
101
|
var isDragingRef = useRef(false);
|
|
@@ -133,26 +135,27 @@ export var VideoPlayer = function (props) {
|
|
|
133
135
|
updatePlayTimeFunRef.current = updatePlayTime;
|
|
134
136
|
});
|
|
135
137
|
useEffect(function () {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
updatePlayTimeFunRef.current
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
138
|
+
// 如果是直播流则不需要处理进度条
|
|
139
|
+
if (!isStreaming) {
|
|
140
|
+
updatePlayTimeFunRef.current = updatePlayTime;
|
|
141
|
+
var interval_1 = setInterval(function () {
|
|
142
|
+
updatePlayTimeFunRef.current();
|
|
143
|
+
}, 1000);
|
|
144
|
+
var playTime = refVideo.current.currentTime;
|
|
145
|
+
var currentSeconds = Math.floor(playTime / 1000 + 0.5);
|
|
146
|
+
var duration = getDuration();
|
|
147
|
+
if (duration == undefined) {
|
|
148
|
+
console.error('该版本的pixui不支持自动获取视频时长,请手动传入videoDuration');
|
|
149
|
+
}
|
|
150
|
+
var totalSeconds = Math.floor(duration / 1000 + 0.5);
|
|
151
|
+
setCurrentTime(currentSeconds);
|
|
152
|
+
setTotalTime(totalSeconds);
|
|
153
|
+
return function () {
|
|
154
|
+
clearInterval(interval_1);
|
|
155
|
+
clearInterval(sliderTimmer.current);
|
|
156
|
+
};
|
|
147
157
|
}
|
|
148
|
-
|
|
149
|
-
setCurrentTime(currentSeconds);
|
|
150
|
-
setTotalTime(totalSeconds);
|
|
151
|
-
return function () {
|
|
152
|
-
clearInterval(interval);
|
|
153
|
-
clearInterval(sliderTimmer.current);
|
|
154
|
-
};
|
|
155
|
-
}, []);
|
|
158
|
+
}, [playUrl]);
|
|
156
159
|
// 开始拖就长显Bar
|
|
157
160
|
var onSliderDragStart = function () {
|
|
158
161
|
videoLog('onDragStart-----------------');
|
|
@@ -279,6 +282,10 @@ export var VideoPlayer = function (props) {
|
|
|
279
282
|
load: function () {
|
|
280
283
|
refVideo.current.load();
|
|
281
284
|
},
|
|
285
|
+
setMute: function (_muted) {
|
|
286
|
+
refVideo.current.muted = _muted;
|
|
287
|
+
setIsMuted(_muted);
|
|
288
|
+
},
|
|
282
289
|
getPlayStatus: function () {
|
|
283
290
|
return videoStatus;
|
|
284
291
|
},
|
|
@@ -298,8 +305,15 @@ export var VideoPlayer = function (props) {
|
|
|
298
305
|
}, 3000);
|
|
299
306
|
}
|
|
300
307
|
},
|
|
308
|
+
setCurrentVolume: function (volume) {
|
|
309
|
+
refVideo.current.volume = volume;
|
|
310
|
+
setCurrentVolume(volume);
|
|
311
|
+
},
|
|
301
312
|
currentTime: currentTime,
|
|
302
313
|
totalTime: totalTime,
|
|
314
|
+
isUIShow: showSlider,
|
|
315
|
+
currentVolume: currentVolume,
|
|
316
|
+
isMuted: isMuted
|
|
303
317
|
};
|
|
304
318
|
}
|
|
305
319
|
// videoLog('currentTime', currentTime, 'totalTime', totalTime);
|
|
@@ -341,7 +355,7 @@ export var VideoPlayer = function (props) {
|
|
|
341
355
|
console.warn('onloadeddata');
|
|
342
356
|
}, onCanPlay: onplaying,
|
|
343
357
|
//@ts-ignore
|
|
344
|
-
onfirstframe: onFirstFrame }),
|
|
358
|
+
onfirstframe: onFirstFrame, controls: true }),
|
|
345
359
|
h("div", { style: screenClickerStyle, onClick: function (e) {
|
|
346
360
|
videoLog('screenClickerStyle click');
|
|
347
361
|
e.stopPropagation();
|