pb-sxp-ui 1.15.22-alpha.3 → 1.15.22-alpha.5
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/dist/index.cjs +24 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -21
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +6 -6
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +24 -21
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +6 -6
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/VideoWidget/index.js +24 -21
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +24 -21
- package/package.json +1 -1
@@ -8,6 +8,7 @@ import { mountVideoPlayerAtNode } from './VideoPlayer';
|
|
8
8
|
import { useSxpDataSource } from '../../../../core/hooks';
|
9
9
|
import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
|
10
10
|
const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon, loopPlay, swiperRef }, ref) => {
|
11
|
+
var _a, _b;
|
11
12
|
const [isPauseVideo, setIsPauseVideo] = useState(false);
|
12
13
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport, isDiyH5 } = useSxpDataSource();
|
13
14
|
const videoStartTime = useRef(0);
|
@@ -25,6 +26,9 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
25
26
|
const isFirstPlayRef = useRef(true);
|
26
27
|
const loopPlayRef = useRef(loopPlay);
|
27
28
|
const scene = rec.video.scene;
|
29
|
+
const videoUrl = (scene === null || scene === void 0 ? void 0 : scene.mediaUrl) || ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url);
|
30
|
+
const videoCover = (scene === null || scene === void 0 ? void 0 : scene.mediaUrl) ? scene === null || scene === void 0 ? void 0 : scene.cover : (_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.cover;
|
31
|
+
const videoPoster = videoCover || (sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image);
|
28
32
|
useImperativeHandle(ref, () => {
|
29
33
|
return {
|
30
34
|
setLoopPlay(v) {
|
@@ -45,8 +49,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
45
49
|
: 'translateY(-50%)';
|
46
50
|
}, [videoPostConfig]);
|
47
51
|
const blurBgSrc = useMemo(() => {
|
48
|
-
|
49
|
-
return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
|
52
|
+
return videoCover || firstFrameSrc;
|
50
53
|
}, [firstFrameSrc, rec]);
|
51
54
|
const blurStyle = useMemo(() => {
|
52
55
|
return blur
|
@@ -81,28 +84,32 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
81
84
|
setIsLoadFinish(true);
|
82
85
|
}, []);
|
83
86
|
const handleStartPlay = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
84
|
-
var
|
87
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
85
88
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
86
89
|
return;
|
87
90
|
setIsPauseVideo(false);
|
88
91
|
const item = data[index];
|
89
|
-
if (item && ((
|
90
|
-
videoStartTime.current = ((
|
91
|
-
const videoDuration = ((
|
92
|
-
const videoCurrentTime = ((
|
92
|
+
if (item && ((_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.duration)) {
|
93
|
+
videoStartTime.current = ((_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) || 0;
|
94
|
+
const videoDuration = ((_f = (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) !== null && _f !== void 0 ? _f : 0).toFixed(2);
|
95
|
+
const videoCurrentTime = ((_h = (_g = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _g === void 0 ? void 0 : _g.currentTime) !== null && _h !== void 0 ? _h : 0).toFixed(2);
|
93
96
|
const playType = (isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) ? '0' : '1';
|
94
97
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
95
|
-
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (
|
98
|
+
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (_k = (_j = item === null || item === void 0 ? void 0 : item.video) === null || _j === void 0 ? void 0 : _j.itemId) !== null && _k !== void 0 ? _k : '', contentName: (_m = (_l = item === null || item === void 0 ? void 0 : item.video) === null || _l === void 0 ? void 0 : _l.title) !== null && _m !== void 0 ? _m : '', playType, startTime: videoCurrentTime, videoDuration, contentTags: JSON.stringify((_p = (_o = item === null || item === void 0 ? void 0 : item.video) === null || _o === void 0 ? void 0 : _o.tags) !== null && _p !== void 0 ? _p : []), position: index + '', contentFormat: 'video', traceInfo: (_q = item === null || item === void 0 ? void 0 : item.video) === null || _q === void 0 ? void 0 : _q.traceInfo }, ((isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) && { loadTime: (loadedTimeRef === null || loadedTimeRef === void 0 ? void 0 : loadedTimeRef.current) - (initTimeRef === null || initTimeRef === void 0 ? void 0 : initTimeRef.current) + '' }))
|
96
99
|
});
|
97
100
|
isFirstPlayRef.current = false;
|
98
101
|
}
|
99
102
|
}), [bffEventReport, data, index, isFirstPlayRef, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
103
|
+
const setCurrentTimeByStartTime = useCallback(() => {
|
104
|
+
if (isDiyH5) {
|
105
|
+
videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
|
106
|
+
}
|
107
|
+
}, []);
|
100
108
|
const handLoadeddata = useCallback(() => {
|
101
|
-
var _a;
|
102
109
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
103
110
|
return;
|
104
111
|
videoRef.current.style.objectFit = 'contain';
|
105
|
-
if (
|
112
|
+
if (videoCover || !canvasRef || !canvasRef.current || isBgColor)
|
106
113
|
return;
|
107
114
|
const setFrameImg = () => {
|
108
115
|
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
@@ -122,9 +129,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
122
129
|
const handleLoadedmetadata = useCallback(() => {
|
123
130
|
if (!videoRef.current)
|
124
131
|
return;
|
125
|
-
|
126
|
-
videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
|
127
|
-
}
|
132
|
+
setCurrentTimeByStartTime();
|
128
133
|
loadedTimeRef.current = new Date();
|
129
134
|
handleStartPlay();
|
130
135
|
handLoadeddata();
|
@@ -218,7 +223,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
218
223
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
219
224
|
if (!isActive)
|
220
225
|
return;
|
221
|
-
const videoSrc =
|
226
|
+
const videoSrc = videoUrl;
|
222
227
|
if (!videoSrc)
|
223
228
|
return;
|
224
229
|
const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
|
@@ -236,7 +241,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
236
241
|
hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
|
237
242
|
hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
238
243
|
var _a;
|
239
|
-
|
244
|
+
setCurrentTimeByStartTime();
|
240
245
|
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
241
246
|
});
|
242
247
|
}
|
@@ -319,8 +324,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
319
324
|
};
|
320
325
|
}, [handleClickVideo, isActive]);
|
321
326
|
const renderPoster = useMemo(() => {
|
322
|
-
|
323
|
-
if ((!((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) && !(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image)) || isLoadFinish) {
|
327
|
+
if (!videoPoster || isLoadFinish) {
|
324
328
|
return null;
|
325
329
|
}
|
326
330
|
return (React.createElement("img", { style: {
|
@@ -330,8 +334,8 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
330
334
|
width: '100%',
|
331
335
|
height: '100%',
|
332
336
|
objectFit: 'cover'
|
333
|
-
}, src:
|
334
|
-
}, [
|
337
|
+
}, src: videoPoster, alt: 'placeholder image' }));
|
338
|
+
}, [isLoadFinish]);
|
335
339
|
const renderLoading = useMemo(() => {
|
336
340
|
if (!waiting || !isLoadFinish)
|
337
341
|
return;
|
@@ -351,8 +355,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
351
355
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
352
356
|
return;
|
353
357
|
const handleBeforeUnload = () => {
|
354
|
-
|
355
|
-
if (activeIndex === index && ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) && !isPauseVideo) {
|
358
|
+
if (activeIndex === index && videoUrl && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) && !isPauseVideo) {
|
356
359
|
handleClickVideo('pause')();
|
357
360
|
}
|
358
361
|
};
|
@@ -10,6 +10,7 @@ const VideoPlayer_1 = require("./VideoPlayer");
|
|
10
10
|
const hooks_1 = require("../../../../core/hooks");
|
11
11
|
const event_1 = tslib_1.__importStar(require("../../../../core/utils/event"));
|
12
12
|
const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon, loopPlay, swiperRef }, ref) => {
|
13
|
+
var _a, _b;
|
13
14
|
const [isPauseVideo, setIsPauseVideo] = (0, react_1.useState)(false);
|
14
15
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport, isDiyH5 } = (0, hooks_1.useSxpDataSource)();
|
15
16
|
const videoStartTime = (0, react_1.useRef)(0);
|
@@ -27,6 +28,9 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
27
28
|
const isFirstPlayRef = (0, react_1.useRef)(true);
|
28
29
|
const loopPlayRef = (0, react_1.useRef)(loopPlay);
|
29
30
|
const scene = rec.video.scene;
|
31
|
+
const videoUrl = (scene === null || scene === void 0 ? void 0 : scene.mediaUrl) || ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url);
|
32
|
+
const videoCover = (scene === null || scene === void 0 ? void 0 : scene.mediaUrl) ? scene === null || scene === void 0 ? void 0 : scene.cover : (_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.cover;
|
33
|
+
const videoPoster = videoCover || (sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image);
|
30
34
|
(0, react_1.useImperativeHandle)(ref, () => {
|
31
35
|
return {
|
32
36
|
setLoopPlay(v) {
|
@@ -47,8 +51,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
47
51
|
: 'translateY(-50%)';
|
48
52
|
}, [videoPostConfig]);
|
49
53
|
const blurBgSrc = (0, react_1.useMemo)(() => {
|
50
|
-
|
51
|
-
return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
|
54
|
+
return videoCover || firstFrameSrc;
|
52
55
|
}, [firstFrameSrc, rec]);
|
53
56
|
const blurStyle = (0, react_1.useMemo)(() => {
|
54
57
|
return blur
|
@@ -83,28 +86,32 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
83
86
|
setIsLoadFinish(true);
|
84
87
|
}, []);
|
85
88
|
const handleStartPlay = (0, react_1.useCallback)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
86
|
-
var
|
89
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
87
90
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
88
91
|
return;
|
89
92
|
setIsPauseVideo(false);
|
90
93
|
const item = data[index];
|
91
|
-
if (item && ((
|
92
|
-
videoStartTime.current = ((
|
93
|
-
const videoDuration = ((
|
94
|
-
const videoCurrentTime = ((
|
94
|
+
if (item && ((_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.duration)) {
|
95
|
+
videoStartTime.current = ((_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) || 0;
|
96
|
+
const videoDuration = ((_f = (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) !== null && _f !== void 0 ? _f : 0).toFixed(2);
|
97
|
+
const videoCurrentTime = ((_h = (_g = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _g === void 0 ? void 0 : _g.currentTime) !== null && _h !== void 0 ? _h : 0).toFixed(2);
|
95
98
|
const playType = (isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) ? '0' : '1';
|
96
99
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
97
|
-
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (
|
100
|
+
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (_k = (_j = item === null || item === void 0 ? void 0 : item.video) === null || _j === void 0 ? void 0 : _j.itemId) !== null && _k !== void 0 ? _k : '', contentName: (_m = (_l = item === null || item === void 0 ? void 0 : item.video) === null || _l === void 0 ? void 0 : _l.title) !== null && _m !== void 0 ? _m : '', playType, startTime: videoCurrentTime, videoDuration, contentTags: JSON.stringify((_p = (_o = item === null || item === void 0 ? void 0 : item.video) === null || _o === void 0 ? void 0 : _o.tags) !== null && _p !== void 0 ? _p : []), position: index + '', contentFormat: 'video', traceInfo: (_q = item === null || item === void 0 ? void 0 : item.video) === null || _q === void 0 ? void 0 : _q.traceInfo }, ((isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) && { loadTime: (loadedTimeRef === null || loadedTimeRef === void 0 ? void 0 : loadedTimeRef.current) - (initTimeRef === null || initTimeRef === void 0 ? void 0 : initTimeRef.current) + '' }))
|
98
101
|
});
|
99
102
|
isFirstPlayRef.current = false;
|
100
103
|
}
|
101
104
|
}), [bffEventReport, data, index, isFirstPlayRef, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
105
|
+
const setCurrentTimeByStartTime = (0, react_1.useCallback)(() => {
|
106
|
+
if (isDiyH5) {
|
107
|
+
videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
|
108
|
+
}
|
109
|
+
}, []);
|
102
110
|
const handLoadeddata = (0, react_1.useCallback)(() => {
|
103
|
-
var _a;
|
104
111
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
105
112
|
return;
|
106
113
|
videoRef.current.style.objectFit = 'contain';
|
107
|
-
if (
|
114
|
+
if (videoCover || !canvasRef || !canvasRef.current || isBgColor)
|
108
115
|
return;
|
109
116
|
const setFrameImg = () => {
|
110
117
|
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
@@ -124,9 +131,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
124
131
|
const handleLoadedmetadata = (0, react_1.useCallback)(() => {
|
125
132
|
if (!videoRef.current)
|
126
133
|
return;
|
127
|
-
|
128
|
-
videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
|
129
|
-
}
|
134
|
+
setCurrentTimeByStartTime();
|
130
135
|
loadedTimeRef.current = new Date();
|
131
136
|
handleStartPlay();
|
132
137
|
handLoadeddata();
|
@@ -220,7 +225,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
220
225
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
221
226
|
if (!isActive)
|
222
227
|
return;
|
223
|
-
const videoSrc =
|
228
|
+
const videoSrc = videoUrl;
|
224
229
|
if (!videoSrc)
|
225
230
|
return;
|
226
231
|
const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
|
@@ -238,7 +243,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
238
243
|
hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
|
239
244
|
hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
240
245
|
var _a;
|
241
|
-
|
246
|
+
setCurrentTimeByStartTime();
|
242
247
|
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
243
248
|
});
|
244
249
|
}
|
@@ -321,8 +326,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
321
326
|
};
|
322
327
|
}, [handleClickVideo, isActive]);
|
323
328
|
const renderPoster = (0, react_1.useMemo)(() => {
|
324
|
-
|
325
|
-
if ((!((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) && !(sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image)) || isLoadFinish) {
|
329
|
+
if (!videoPoster || isLoadFinish) {
|
326
330
|
return null;
|
327
331
|
}
|
328
332
|
return (react_1.default.createElement("img", { style: {
|
@@ -332,8 +336,8 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
332
336
|
width: '100%',
|
333
337
|
height: '100%',
|
334
338
|
objectFit: 'cover'
|
335
|
-
}, src:
|
336
|
-
}, [
|
339
|
+
}, src: videoPoster, alt: 'placeholder image' }));
|
340
|
+
}, [isLoadFinish]);
|
337
341
|
const renderLoading = (0, react_1.useMemo)(() => {
|
338
342
|
if (!waiting || !isLoadFinish)
|
339
343
|
return;
|
@@ -353,8 +357,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
353
357
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
354
358
|
return;
|
355
359
|
const handleBeforeUnload = () => {
|
356
|
-
|
357
|
-
if (activeIndex === index && ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) && !isPauseVideo) {
|
360
|
+
if (activeIndex === index && videoUrl && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) && !isPauseVideo) {
|
358
361
|
handleClickVideo('pause')();
|
359
362
|
}
|
360
363
|
};
|