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
package/dist/pb-ui.js
CHANGED
@@ -17677,6 +17677,7 @@ Made in Italy` })));
|
|
17677
17677
|
})();
|
17678
17678
|
|
17679
17679
|
const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon, loopPlay, swiperRef }, ref) => {
|
17680
|
+
var _a, _b;
|
17680
17681
|
const [isPauseVideo, setIsPauseVideo] = React.useState(false);
|
17681
17682
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport, isDiyH5 } = useSxpDataSource();
|
17682
17683
|
const videoStartTime = React.useRef(0);
|
@@ -17694,6 +17695,9 @@ Made in Italy` })));
|
|
17694
17695
|
const isFirstPlayRef = React.useRef(true);
|
17695
17696
|
const loopPlayRef = React.useRef(loopPlay);
|
17696
17697
|
const scene = rec.video.scene;
|
17698
|
+
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);
|
17699
|
+
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;
|
17700
|
+
const videoPoster = videoCover || (sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image);
|
17697
17701
|
React.useImperativeHandle(ref, () => {
|
17698
17702
|
return {
|
17699
17703
|
setLoopPlay(v) {
|
@@ -17714,8 +17718,7 @@ Made in Italy` })));
|
|
17714
17718
|
: 'translateY(-50%)';
|
17715
17719
|
}, [videoPostConfig]);
|
17716
17720
|
const blurBgSrc = React.useMemo(() => {
|
17717
|
-
|
17718
|
-
return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
|
17721
|
+
return videoCover || firstFrameSrc;
|
17719
17722
|
}, [firstFrameSrc, rec]);
|
17720
17723
|
const blurStyle = React.useMemo(() => {
|
17721
17724
|
return blur
|
@@ -17750,28 +17753,32 @@ Made in Italy` })));
|
|
17750
17753
|
setIsLoadFinish(true);
|
17751
17754
|
}, []);
|
17752
17755
|
const handleStartPlay = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
17753
|
-
var
|
17756
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
17754
17757
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
17755
17758
|
return;
|
17756
17759
|
setIsPauseVideo(false);
|
17757
17760
|
const item = data[index];
|
17758
|
-
if (item && ((
|
17759
|
-
videoStartTime.current = ((
|
17760
|
-
const videoDuration = ((
|
17761
|
-
const videoCurrentTime = ((
|
17761
|
+
if (item && ((_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.duration)) {
|
17762
|
+
videoStartTime.current = ((_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) || 0;
|
17763
|
+
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);
|
17764
|
+
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);
|
17762
17765
|
const playType = (isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) ? '0' : '1';
|
17763
17766
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
17764
|
-
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (
|
17767
|
+
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) + '' }))
|
17765
17768
|
});
|
17766
17769
|
isFirstPlayRef.current = false;
|
17767
17770
|
}
|
17768
17771
|
}), [bffEventReport, data, index, isFirstPlayRef, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
17772
|
+
const setCurrentTimeByStartTime = React.useCallback(() => {
|
17773
|
+
if (isDiyH5) {
|
17774
|
+
videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
|
17775
|
+
}
|
17776
|
+
}, []);
|
17769
17777
|
const handLoadeddata = React.useCallback(() => {
|
17770
|
-
var _a;
|
17771
17778
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
17772
17779
|
return;
|
17773
17780
|
videoRef.current.style.objectFit = 'contain';
|
17774
|
-
if (
|
17781
|
+
if (videoCover || !canvasRef || !canvasRef.current || isBgColor)
|
17775
17782
|
return;
|
17776
17783
|
const setFrameImg = () => {
|
17777
17784
|
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
@@ -17791,9 +17798,7 @@ Made in Italy` })));
|
|
17791
17798
|
const handleLoadedmetadata = React.useCallback(() => {
|
17792
17799
|
if (!videoRef.current)
|
17793
17800
|
return;
|
17794
|
-
|
17795
|
-
videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
|
17796
|
-
}
|
17801
|
+
setCurrentTimeByStartTime();
|
17797
17802
|
loadedTimeRef.current = new Date();
|
17798
17803
|
handleStartPlay();
|
17799
17804
|
handLoadeddata();
|
@@ -17887,7 +17892,7 @@ Made in Italy` })));
|
|
17887
17892
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
17888
17893
|
if (!isActive)
|
17889
17894
|
return;
|
17890
|
-
const videoSrc =
|
17895
|
+
const videoSrc = videoUrl;
|
17891
17896
|
if (!videoSrc)
|
17892
17897
|
return;
|
17893
17898
|
const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
|
@@ -17905,7 +17910,7 @@ Made in Italy` })));
|
|
17905
17910
|
hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
|
17906
17911
|
hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
17907
17912
|
var _a;
|
17908
|
-
|
17913
|
+
setCurrentTimeByStartTime();
|
17909
17914
|
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
17910
17915
|
});
|
17911
17916
|
}
|
@@ -17991,8 +17996,7 @@ Made in Italy` })));
|
|
17991
17996
|
};
|
17992
17997
|
}, [handleClickVideo, isActive]);
|
17993
17998
|
const renderPoster = React.useMemo(() => {
|
17994
|
-
|
17995
|
-
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) {
|
17999
|
+
if (!videoPoster || isLoadFinish) {
|
17996
18000
|
return null;
|
17997
18001
|
}
|
17998
18002
|
return (React.createElement("img", { style: {
|
@@ -18002,8 +18006,8 @@ Made in Italy` })));
|
|
18002
18006
|
width: '100%',
|
18003
18007
|
height: '100%',
|
18004
18008
|
objectFit: 'cover'
|
18005
|
-
}, src:
|
18006
|
-
}, [
|
18009
|
+
}, src: videoPoster, alt: 'placeholder image' }));
|
18010
|
+
}, [isLoadFinish]);
|
18007
18011
|
const renderLoading = React.useMemo(() => {
|
18008
18012
|
if (!waiting || !isLoadFinish)
|
18009
18013
|
return;
|
@@ -18023,8 +18027,7 @@ Made in Italy` })));
|
|
18023
18027
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
18024
18028
|
return;
|
18025
18029
|
const handleBeforeUnload = () => {
|
18026
|
-
|
18027
|
-
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) {
|
18030
|
+
if (activeIndex === index && videoUrl && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) && !isPauseVideo) {
|
18028
18031
|
handleClickVideo('pause')();
|
18029
18032
|
}
|
18030
18033
|
};
|