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/index.cjs
CHANGED
@@ -17684,6 +17684,7 @@ const mountVideoPlayerAtNode = (() => {
|
|
17684
17684
|
})();
|
17685
17685
|
|
17686
17686
|
const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon, loopPlay, swiperRef }, ref) => {
|
17687
|
+
var _a, _b;
|
17687
17688
|
const [isPauseVideo, setIsPauseVideo] = React.useState(false);
|
17688
17689
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport, isDiyH5 } = useSxpDataSource();
|
17689
17690
|
const videoStartTime = React.useRef(0);
|
@@ -17701,6 +17702,9 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
17701
17702
|
const isFirstPlayRef = React.useRef(true);
|
17702
17703
|
const loopPlayRef = React.useRef(loopPlay);
|
17703
17704
|
const scene = rec.video.scene;
|
17705
|
+
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);
|
17706
|
+
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;
|
17707
|
+
const videoPoster = videoCover || (sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image);
|
17704
17708
|
React.useImperativeHandle(ref, () => {
|
17705
17709
|
return {
|
17706
17710
|
setLoopPlay(v) {
|
@@ -17721,8 +17725,7 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
17721
17725
|
: 'translateY(-50%)';
|
17722
17726
|
}, [videoPostConfig]);
|
17723
17727
|
const blurBgSrc = React.useMemo(() => {
|
17724
|
-
|
17725
|
-
return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
|
17728
|
+
return videoCover || firstFrameSrc;
|
17726
17729
|
}, [firstFrameSrc, rec]);
|
17727
17730
|
const blurStyle = React.useMemo(() => {
|
17728
17731
|
return blur
|
@@ -17757,28 +17760,32 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
17757
17760
|
setIsLoadFinish(true);
|
17758
17761
|
}, []);
|
17759
17762
|
const handleStartPlay = React.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
17760
|
-
var
|
17763
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
17761
17764
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
17762
17765
|
return;
|
17763
17766
|
setIsPauseVideo(false);
|
17764
17767
|
const item = data[index];
|
17765
|
-
if (item && ((
|
17766
|
-
videoStartTime.current = ((
|
17767
|
-
const videoDuration = ((
|
17768
|
-
const videoCurrentTime = ((
|
17768
|
+
if (item && ((_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.duration)) {
|
17769
|
+
videoStartTime.current = ((_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) || 0;
|
17770
|
+
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);
|
17771
|
+
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);
|
17769
17772
|
const playType = (isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) ? '0' : '1';
|
17770
17773
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
17771
|
-
eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (
|
17774
|
+
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) + '' }))
|
17772
17775
|
});
|
17773
17776
|
isFirstPlayRef.current = false;
|
17774
17777
|
}
|
17775
17778
|
}), [bffEventReport, data, index, isFirstPlayRef, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
17779
|
+
const setCurrentTimeByStartTime = React.useCallback(() => {
|
17780
|
+
if (isDiyH5) {
|
17781
|
+
videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
|
17782
|
+
}
|
17783
|
+
}, []);
|
17776
17784
|
const handLoadeddata = React.useCallback(() => {
|
17777
|
-
var _a;
|
17778
17785
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
17779
17786
|
return;
|
17780
17787
|
videoRef.current.style.objectFit = 'contain';
|
17781
|
-
if (
|
17788
|
+
if (videoCover || !canvasRef || !canvasRef.current || isBgColor)
|
17782
17789
|
return;
|
17783
17790
|
const setFrameImg = () => {
|
17784
17791
|
const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
|
@@ -17798,9 +17805,7 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
17798
17805
|
const handleLoadedmetadata = React.useCallback(() => {
|
17799
17806
|
if (!videoRef.current)
|
17800
17807
|
return;
|
17801
|
-
|
17802
|
-
videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
|
17803
|
-
}
|
17808
|
+
setCurrentTimeByStartTime();
|
17804
17809
|
loadedTimeRef.current = new Date();
|
17805
17810
|
handleStartPlay();
|
17806
17811
|
handLoadeddata();
|
@@ -17894,7 +17899,7 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
17894
17899
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
17895
17900
|
if (!isActive)
|
17896
17901
|
return;
|
17897
|
-
const videoSrc =
|
17902
|
+
const videoSrc = videoUrl;
|
17898
17903
|
if (!videoSrc)
|
17899
17904
|
return;
|
17900
17905
|
const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
|
@@ -17912,7 +17917,7 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
17912
17917
|
hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
|
17913
17918
|
hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
17914
17919
|
var _a;
|
17915
|
-
|
17920
|
+
setCurrentTimeByStartTime();
|
17916
17921
|
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
17917
17922
|
});
|
17918
17923
|
}
|
@@ -17998,8 +18003,7 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
17998
18003
|
};
|
17999
18004
|
}, [handleClickVideo, isActive]);
|
18000
18005
|
const renderPoster = React.useMemo(() => {
|
18001
|
-
|
18002
|
-
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) {
|
18006
|
+
if (!videoPoster || isLoadFinish) {
|
18003
18007
|
return null;
|
18004
18008
|
}
|
18005
18009
|
return (React.createElement("img", { style: {
|
@@ -18009,8 +18013,8 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
18009
18013
|
width: '100%',
|
18010
18014
|
height: '100%',
|
18011
18015
|
objectFit: 'cover'
|
18012
|
-
}, src:
|
18013
|
-
}, [
|
18016
|
+
}, src: videoPoster, alt: 'placeholder image' }));
|
18017
|
+
}, [isLoadFinish]);
|
18014
18018
|
const renderLoading = React.useMemo(() => {
|
18015
18019
|
if (!waiting || !isLoadFinish)
|
18016
18020
|
return;
|
@@ -18030,8 +18034,7 @@ const VideoWidget$4 = React.forwardRef(({ rec, index, height, data, muted, activ
|
|
18030
18034
|
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
18031
18035
|
return;
|
18032
18036
|
const handleBeforeUnload = () => {
|
18033
|
-
|
18034
|
-
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) {
|
18037
|
+
if (activeIndex === index && videoUrl && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) && !isPauseVideo) {
|
18035
18038
|
handleClickVideo('pause')();
|
18036
18039
|
}
|
18037
18040
|
};
|