pb-sxp-ui 1.15.22-alpha.3 → 1.15.22-alpha.4
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 +19 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -17
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +19 -17
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/VideoWidget/index.js +19 -17
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +19 -17
- 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, _c, _d, _e;
|
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,11 @@ 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 = (scene === null || scene === void 0 ? void 0 : scene.mediaUrl)
|
32
|
+
? (_c = scene === null || scene === void 0 ? void 0 : scene.cover) !== null && _c !== void 0 ? _c : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image
|
33
|
+
: (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.cover) !== null && _e !== void 0 ? _e : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image;
|
28
34
|
useImperativeHandle(ref, () => {
|
29
35
|
return {
|
30
36
|
setLoopPlay(v) {
|
@@ -45,8 +51,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
45
51
|
: 'translateY(-50%)';
|
46
52
|
}, [videoPostConfig]);
|
47
53
|
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;
|
54
|
+
return videoCover || firstFrameSrc;
|
50
55
|
}, [firstFrameSrc, rec]);
|
51
56
|
const blurStyle = useMemo(() => {
|
52
57
|
return blur
|
@@ -81,28 +86,27 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
81
86
|
setIsLoadFinish(true);
|
82
87
|
}, []);
|
83
88
|
const handleStartPlay = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
84
|
-
var
|
89
|
+
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
85
90
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
86
91
|
return;
|
87
92
|
setIsPauseVideo(false);
|
88
93
|
const item = data[index];
|
89
|
-
if (item && ((
|
90
|
-
videoStartTime.current = ((
|
91
|
-
const videoDuration = ((
|
92
|
-
const videoCurrentTime = ((
|
94
|
+
if (item && ((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.duration)) {
|
95
|
+
videoStartTime.current = ((_g = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _g === void 0 ? void 0 : _g.currentTime) || 0;
|
96
|
+
const videoDuration = ((_j = (_h = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _h === void 0 ? void 0 : _h.duration) !== null && _j !== void 0 ? _j : 0).toFixed(2);
|
97
|
+
const videoCurrentTime = ((_l = (_k = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _k === void 0 ? void 0 : _k.currentTime) !== null && _l !== void 0 ? _l : 0).toFixed(2);
|
93
98
|
const playType = (isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) ? '0' : '1';
|
94
99
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
95
|
-
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (
|
100
|
+
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (_o = (_m = item === null || item === void 0 ? void 0 : item.video) === null || _m === void 0 ? void 0 : _m.itemId) !== null && _o !== void 0 ? _o : '', contentName: (_q = (_p = item === null || item === void 0 ? void 0 : item.video) === null || _p === void 0 ? void 0 : _p.title) !== null && _q !== void 0 ? _q : '', playType, startTime: videoCurrentTime, videoDuration, contentTags: JSON.stringify((_s = (_r = item === null || item === void 0 ? void 0 : item.video) === null || _r === void 0 ? void 0 : _r.tags) !== null && _s !== void 0 ? _s : []), position: index + '', contentFormat: 'video', traceInfo: (_t = item === null || item === void 0 ? void 0 : item.video) === null || _t === void 0 ? void 0 : _t.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
101
|
});
|
97
102
|
isFirstPlayRef.current = false;
|
98
103
|
}
|
99
104
|
}), [bffEventReport, data, index, isFirstPlayRef, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
100
105
|
const handLoadeddata = useCallback(() => {
|
101
|
-
var _a;
|
102
106
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
103
107
|
return;
|
104
108
|
videoRef.current.style.objectFit = 'contain';
|
105
|
-
if (
|
109
|
+
if (videoCover || !canvasRef || !canvasRef.current || isBgColor)
|
106
110
|
return;
|
107
111
|
const setFrameImg = () => {
|
108
112
|
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
@@ -218,7 +222,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
218
222
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
219
223
|
if (!isActive)
|
220
224
|
return;
|
221
|
-
const videoSrc =
|
225
|
+
const videoSrc = videoUrl;
|
222
226
|
if (!videoSrc)
|
223
227
|
return;
|
224
228
|
const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
|
@@ -319,8 +323,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
319
323
|
};
|
320
324
|
}, [handleClickVideo, isActive]);
|
321
325
|
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) {
|
326
|
+
if (!videoPoster || isLoadFinish) {
|
324
327
|
return null;
|
325
328
|
}
|
326
329
|
return (React.createElement("img", { style: {
|
@@ -330,8 +333,8 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
330
333
|
width: '100%',
|
331
334
|
height: '100%',
|
332
335
|
objectFit: 'cover'
|
333
|
-
}, src:
|
334
|
-
}, [
|
336
|
+
}, src: videoPoster, alt: 'placeholder image' }));
|
337
|
+
}, [isLoadFinish]);
|
335
338
|
const renderLoading = useMemo(() => {
|
336
339
|
if (!waiting || !isLoadFinish)
|
337
340
|
return;
|
@@ -351,8 +354,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
351
354
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
352
355
|
return;
|
353
356
|
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) {
|
357
|
+
if (activeIndex === index && videoUrl && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) && !isPauseVideo) {
|
356
358
|
handleClickVideo('pause')();
|
357
359
|
}
|
358
360
|
};
|
@@ -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, _c, _d, _e;
|
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,11 @@ 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 = (scene === null || scene === void 0 ? void 0 : scene.mediaUrl)
|
34
|
+
? (_c = scene === null || scene === void 0 ? void 0 : scene.cover) !== null && _c !== void 0 ? _c : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image
|
35
|
+
: (_e = (_d = rec === null || rec === void 0 ? void 0 : rec.video) === null || _d === void 0 ? void 0 : _d.cover) !== null && _e !== void 0 ? _e : sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image;
|
30
36
|
(0, react_1.useImperativeHandle)(ref, () => {
|
31
37
|
return {
|
32
38
|
setLoopPlay(v) {
|
@@ -47,8 +53,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
47
53
|
: 'translateY(-50%)';
|
48
54
|
}, [videoPostConfig]);
|
49
55
|
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;
|
56
|
+
return videoCover || firstFrameSrc;
|
52
57
|
}, [firstFrameSrc, rec]);
|
53
58
|
const blurStyle = (0, react_1.useMemo)(() => {
|
54
59
|
return blur
|
@@ -83,28 +88,27 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
83
88
|
setIsLoadFinish(true);
|
84
89
|
}, []);
|
85
90
|
const handleStartPlay = (0, react_1.useCallback)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
86
|
-
var
|
91
|
+
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
87
92
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
88
93
|
return;
|
89
94
|
setIsPauseVideo(false);
|
90
95
|
const item = data[index];
|
91
|
-
if (item && ((
|
92
|
-
videoStartTime.current = ((
|
93
|
-
const videoDuration = ((
|
94
|
-
const videoCurrentTime = ((
|
96
|
+
if (item && ((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.duration)) {
|
97
|
+
videoStartTime.current = ((_g = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _g === void 0 ? void 0 : _g.currentTime) || 0;
|
98
|
+
const videoDuration = ((_j = (_h = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _h === void 0 ? void 0 : _h.duration) !== null && _j !== void 0 ? _j : 0).toFixed(2);
|
99
|
+
const videoCurrentTime = ((_l = (_k = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _k === void 0 ? void 0 : _k.currentTime) !== null && _l !== void 0 ? _l : 0).toFixed(2);
|
95
100
|
const playType = (isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) ? '0' : '1';
|
96
101
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
97
|
-
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (
|
102
|
+
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (_o = (_m = item === null || item === void 0 ? void 0 : item.video) === null || _m === void 0 ? void 0 : _m.itemId) !== null && _o !== void 0 ? _o : '', contentName: (_q = (_p = item === null || item === void 0 ? void 0 : item.video) === null || _p === void 0 ? void 0 : _p.title) !== null && _q !== void 0 ? _q : '', playType, startTime: videoCurrentTime, videoDuration, contentTags: JSON.stringify((_s = (_r = item === null || item === void 0 ? void 0 : item.video) === null || _r === void 0 ? void 0 : _r.tags) !== null && _s !== void 0 ? _s : []), position: index + '', contentFormat: 'video', traceInfo: (_t = item === null || item === void 0 ? void 0 : item.video) === null || _t === void 0 ? void 0 : _t.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
103
|
});
|
99
104
|
isFirstPlayRef.current = false;
|
100
105
|
}
|
101
106
|
}), [bffEventReport, data, index, isFirstPlayRef, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
102
107
|
const handLoadeddata = (0, react_1.useCallback)(() => {
|
103
|
-
var _a;
|
104
108
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
105
109
|
return;
|
106
110
|
videoRef.current.style.objectFit = 'contain';
|
107
|
-
if (
|
111
|
+
if (videoCover || !canvasRef || !canvasRef.current || isBgColor)
|
108
112
|
return;
|
109
113
|
const setFrameImg = () => {
|
110
114
|
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
@@ -220,7 +224,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
220
224
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
221
225
|
if (!isActive)
|
222
226
|
return;
|
223
|
-
const videoSrc =
|
227
|
+
const videoSrc = videoUrl;
|
224
228
|
if (!videoSrc)
|
225
229
|
return;
|
226
230
|
const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
|
@@ -321,8 +325,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
321
325
|
};
|
322
326
|
}, [handleClickVideo, isActive]);
|
323
327
|
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) {
|
328
|
+
if (!videoPoster || isLoadFinish) {
|
326
329
|
return null;
|
327
330
|
}
|
328
331
|
return (react_1.default.createElement("img", { style: {
|
@@ -332,8 +335,8 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
332
335
|
width: '100%',
|
333
336
|
height: '100%',
|
334
337
|
objectFit: 'cover'
|
335
|
-
}, src:
|
336
|
-
}, [
|
338
|
+
}, src: videoPoster, alt: 'placeholder image' }));
|
339
|
+
}, [isLoadFinish]);
|
337
340
|
const renderLoading = (0, react_1.useMemo)(() => {
|
338
341
|
if (!waiting || !isLoadFinish)
|
339
342
|
return;
|
@@ -353,8 +356,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
353
356
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
354
357
|
return;
|
355
358
|
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) {
|
359
|
+
if (activeIndex === index && videoUrl && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) && !isPauseVideo) {
|
358
360
|
handleClickVideo('pause')();
|
359
361
|
}
|
360
362
|
};
|