pb-sxp-ui 1.15.22-alpha.4 → 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 +15 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -14
- 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 +15 -14
- 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 +15 -14
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +15 -14
- package/package.json +1 -1
@@ -8,7 +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
|
+
var _a, _b;
|
12
12
|
const [isPauseVideo, setIsPauseVideo] = useState(false);
|
13
13
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport, isDiyH5 } = useSxpDataSource();
|
14
14
|
const videoStartTime = useRef(0);
|
@@ -28,9 +28,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
28
28
|
const scene = rec.video.scene;
|
29
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
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 = (
|
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;
|
31
|
+
const videoPoster = videoCover || (sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image);
|
34
32
|
useImperativeHandle(ref, () => {
|
35
33
|
return {
|
36
34
|
setLoopPlay(v) {
|
@@ -86,22 +84,27 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
86
84
|
setIsLoadFinish(true);
|
87
85
|
}, []);
|
88
86
|
const handleStartPlay = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
89
|
-
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
87
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
90
88
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
91
89
|
return;
|
92
90
|
setIsPauseVideo(false);
|
93
91
|
const item = data[index];
|
94
|
-
if (item && ((
|
95
|
-
videoStartTime.current = ((
|
96
|
-
const videoDuration = ((
|
97
|
-
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);
|
98
96
|
const playType = (isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) ? '0' : '1';
|
99
97
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
100
|
-
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) + '' }))
|
101
99
|
});
|
102
100
|
isFirstPlayRef.current = false;
|
103
101
|
}
|
104
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
|
+
}, []);
|
105
108
|
const handLoadeddata = useCallback(() => {
|
106
109
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
107
110
|
return;
|
@@ -126,9 +129,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
126
129
|
const handleLoadedmetadata = useCallback(() => {
|
127
130
|
if (!videoRef.current)
|
128
131
|
return;
|
129
|
-
|
130
|
-
videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
|
131
|
-
}
|
132
|
+
setCurrentTimeByStartTime();
|
132
133
|
loadedTimeRef.current = new Date();
|
133
134
|
handleStartPlay();
|
134
135
|
handLoadeddata();
|
@@ -240,7 +241,7 @@ const VideoWidget = forwardRef(({ rec, index, height, data, muted, activeIndex,
|
|
240
241
|
hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
|
241
242
|
hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
242
243
|
var _a;
|
243
|
-
|
244
|
+
setCurrentTimeByStartTime();
|
244
245
|
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
245
246
|
});
|
246
247
|
}
|
@@ -10,7 +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
|
+
var _a, _b;
|
14
14
|
const [isPauseVideo, setIsPauseVideo] = (0, react_1.useState)(false);
|
15
15
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport, isDiyH5 } = (0, hooks_1.useSxpDataSource)();
|
16
16
|
const videoStartTime = (0, react_1.useRef)(0);
|
@@ -30,9 +30,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
30
30
|
const scene = rec.video.scene;
|
31
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
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 = (
|
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;
|
33
|
+
const videoPoster = videoCover || (sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image);
|
36
34
|
(0, react_1.useImperativeHandle)(ref, () => {
|
37
35
|
return {
|
38
36
|
setLoopPlay(v) {
|
@@ -88,22 +86,27 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
88
86
|
setIsLoadFinish(true);
|
89
87
|
}, []);
|
90
88
|
const handleStartPlay = (0, react_1.useCallback)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
91
|
-
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
89
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
92
90
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
93
91
|
return;
|
94
92
|
setIsPauseVideo(false);
|
95
93
|
const item = data[index];
|
96
|
-
if (item && ((
|
97
|
-
videoStartTime.current = ((
|
98
|
-
const videoDuration = ((
|
99
|
-
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);
|
100
98
|
const playType = (isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) ? '0' : '1';
|
101
99
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
102
|
-
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) + '' }))
|
103
101
|
});
|
104
102
|
isFirstPlayRef.current = false;
|
105
103
|
}
|
106
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
|
+
}, []);
|
107
110
|
const handLoadeddata = (0, react_1.useCallback)(() => {
|
108
111
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
109
112
|
return;
|
@@ -128,9 +131,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
128
131
|
const handleLoadedmetadata = (0, react_1.useCallback)(() => {
|
129
132
|
if (!videoRef.current)
|
130
133
|
return;
|
131
|
-
|
132
|
-
videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
|
133
|
-
}
|
134
|
+
setCurrentTimeByStartTime();
|
134
135
|
loadedTimeRef.current = new Date();
|
135
136
|
handleStartPlay();
|
136
137
|
handLoadeddata();
|
@@ -242,7 +243,7 @@ const VideoWidget = (0, react_1.forwardRef)(({ rec, index, height, data, muted,
|
|
242
243
|
hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
|
243
244
|
hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
244
245
|
var _a;
|
245
|
-
|
246
|
+
setCurrentTimeByStartTime();
|
246
247
|
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
247
248
|
});
|
248
249
|
}
|