pixuireactcomponents 1.5.21 → 1.5.22
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
|
@@ -97,6 +97,10 @@ export var VideoPlayer = function (props) {
|
|
|
97
97
|
var sliderTimmer = useRef(null);
|
|
98
98
|
var rootRef = useRef();
|
|
99
99
|
var isDragingRef = useRef(false);
|
|
100
|
+
// 在开发setCurrentTime功能时,发现seek视频后立刻pause, 视频会在onpause回调执行后,
|
|
101
|
+
// 又执行一遍onwating, onplaying回调,导致videoStatus被错误设置成播放状态。
|
|
102
|
+
// 暂时使用isPauseSeekingRef来标记是否在暂停状态下setCurrentTime触发,在onplaying中将状态设回Pause
|
|
103
|
+
var isPauseSeekingRef = useRef(false);
|
|
100
104
|
var updatePlayTime = function () {
|
|
101
105
|
if (videoStatus != VideoStatus.Playing || isStreaming)
|
|
102
106
|
return;
|
|
@@ -192,6 +196,11 @@ export var VideoPlayer = function (props) {
|
|
|
192
196
|
var onplaying = function () {
|
|
193
197
|
// 加载第一帧画面
|
|
194
198
|
videoLog('-----------onplaying');
|
|
199
|
+
if (isPauseSeekingRef.current) {
|
|
200
|
+
isPauseSeekingRef.current = false;
|
|
201
|
+
setVideoStatus(VideoStatus.Pause);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
195
204
|
setVideoStatus(VideoStatus.Playing);
|
|
196
205
|
(playEvent === null || playEvent === void 0 ? void 0 : playEvent.onPlay) && playEvent.onPlay();
|
|
197
206
|
};
|
|
@@ -273,8 +282,24 @@ export var VideoPlayer = function (props) {
|
|
|
273
282
|
getPlayStatus: function () {
|
|
274
283
|
return videoStatus;
|
|
275
284
|
},
|
|
285
|
+
setCurrentTime: function (currentTime) {
|
|
286
|
+
var _currentSeconds = Math.floor(currentTime / 1000 + 0.5);
|
|
287
|
+
setCurrentTime(_currentSeconds);
|
|
288
|
+
refVideo.current.seek(_currentSeconds);
|
|
289
|
+
if (videoStatus === VideoStatus.Playing) {
|
|
290
|
+
refVideo.current.play();
|
|
291
|
+
}
|
|
292
|
+
else if (videoStatus === VideoStatus.Pause) {
|
|
293
|
+
isPauseSeekingRef.current = true;
|
|
294
|
+
refVideo.current.pause();
|
|
295
|
+
// 留出3000ms视频加载时间,复位isSeekingRef
|
|
296
|
+
setTimeout(function () {
|
|
297
|
+
isPauseSeekingRef.current = false;
|
|
298
|
+
}, 3000);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
276
301
|
currentTime: currentTime,
|
|
277
|
-
totalTime: totalTime
|
|
302
|
+
totalTime: totalTime,
|
|
278
303
|
};
|
|
279
304
|
}
|
|
280
305
|
// videoLog('currentTime', currentTime, 'totalTime', totalTime);
|