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.js CHANGED
@@ -17662,6 +17662,7 @@ const mountVideoPlayerAtNode = (() => {
17662
17662
  })();
17663
17663
 
17664
17664
  const VideoWidget$4 = forwardRef(({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon, loopPlay, swiperRef }, ref) => {
17665
+ var _a, _b;
17665
17666
  const [isPauseVideo, setIsPauseVideo] = useState(false);
17666
17667
  const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport, isDiyH5 } = useSxpDataSource();
17667
17668
  const videoStartTime = useRef(0);
@@ -17679,6 +17680,9 @@ const VideoWidget$4 = forwardRef(({ rec, index, height, data, muted, activeIndex
17679
17680
  const isFirstPlayRef = useRef(true);
17680
17681
  const loopPlayRef = useRef(loopPlay);
17681
17682
  const scene = rec.video.scene;
17683
+ 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);
17684
+ 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;
17685
+ const videoPoster = videoCover || (sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image);
17682
17686
  useImperativeHandle(ref, () => {
17683
17687
  return {
17684
17688
  setLoopPlay(v) {
@@ -17699,8 +17703,7 @@ const VideoWidget$4 = forwardRef(({ rec, index, height, data, muted, activeIndex
17699
17703
  : 'translateY(-50%)';
17700
17704
  }, [videoPostConfig]);
17701
17705
  const blurBgSrc = useMemo(() => {
17702
- var _a;
17703
- return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
17706
+ return videoCover || firstFrameSrc;
17704
17707
  }, [firstFrameSrc, rec]);
17705
17708
  const blurStyle = useMemo(() => {
17706
17709
  return blur
@@ -17735,28 +17738,32 @@ const VideoWidget$4 = forwardRef(({ rec, index, height, data, muted, activeIndex
17735
17738
  setIsLoadFinish(true);
17736
17739
  }, []);
17737
17740
  const handleStartPlay = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
17738
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
17741
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
17739
17742
  if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
17740
17743
  return;
17741
17744
  setIsPauseVideo(false);
17742
17745
  const item = data[index];
17743
- if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
17744
- videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
17745
- const videoDuration = ((_d = (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
17746
- const videoCurrentTime = ((_f = (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
17746
+ if (item && ((_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.duration)) {
17747
+ videoStartTime.current = ((_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.currentTime) || 0;
17748
+ 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);
17749
+ 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);
17747
17750
  const playType = (isFirstPlayRef === null || isFirstPlayRef === void 0 ? void 0 : isFirstPlayRef.current) ? '0' : '1';
17748
17751
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
17749
- eventInfo: Object.assign({ eventSubject: 'playVideo', eventDescription: 'User played the video', contentId: (_h = (_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.itemId) !== null && _h !== void 0 ? _h : '', contentName: (_k = (_j = item === null || item === void 0 ? void 0 : item.video) === null || _j === void 0 ? void 0 : _j.title) !== null && _k !== void 0 ? _k : '', playType, startTime: videoCurrentTime, videoDuration, contentTags: JSON.stringify((_m = (_l = item === null || item === void 0 ? void 0 : item.video) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : []), position: index + '', contentFormat: 'video', traceInfo: (_o = item === null || item === void 0 ? void 0 : item.video) === null || _o === void 0 ? void 0 : _o.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) + '' }))
17752
+ 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) + '' }))
17750
17753
  });
17751
17754
  isFirstPlayRef.current = false;
17752
17755
  }
17753
17756
  }), [bffEventReport, data, index, isFirstPlayRef, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
17757
+ const setCurrentTimeByStartTime = useCallback(() => {
17758
+ if (isDiyH5) {
17759
+ videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
17760
+ }
17761
+ }, []);
17754
17762
  const handLoadeddata = useCallback(() => {
17755
- var _a;
17756
17763
  if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
17757
17764
  return;
17758
17765
  videoRef.current.style.objectFit = 'contain';
17759
- if (((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || !canvasRef || !canvasRef.current || isBgColor)
17766
+ if (videoCover || !canvasRef || !canvasRef.current || isBgColor)
17760
17767
  return;
17761
17768
  const setFrameImg = () => {
17762
17769
  const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
@@ -17776,9 +17783,7 @@ const VideoWidget$4 = forwardRef(({ rec, index, height, data, muted, activeIndex
17776
17783
  const handleLoadedmetadata = useCallback(() => {
17777
17784
  if (!videoRef.current)
17778
17785
  return;
17779
- if (isDiyH5) {
17780
- videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
17781
- }
17786
+ setCurrentTimeByStartTime();
17782
17787
  loadedTimeRef.current = new Date();
17783
17788
  handleStartPlay();
17784
17789
  handLoadeddata();
@@ -17872,7 +17877,7 @@ const VideoWidget$4 = forwardRef(({ rec, index, height, data, muted, activeIndex
17872
17877
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
17873
17878
  if (!isActive)
17874
17879
  return;
17875
- const videoSrc = rec === null || rec === void 0 ? void 0 : rec.video.url;
17880
+ const videoSrc = videoUrl;
17876
17881
  if (!videoSrc)
17877
17882
  return;
17878
17883
  const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
@@ -17890,7 +17895,7 @@ const VideoWidget$4 = forwardRef(({ rec, index, height, data, muted, activeIndex
17890
17895
  hls === null || hls === void 0 ? void 0 : hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
17891
17896
  hls === null || hls === void 0 ? void 0 : hls.on(Hls.Events.MANIFEST_PARSED, function () {
17892
17897
  var _a;
17893
- videoRef.current.currentTime = scene === null || scene === void 0 ? void 0 : scene.startTime;
17898
+ setCurrentTimeByStartTime();
17894
17899
  (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
17895
17900
  });
17896
17901
  }
@@ -17976,8 +17981,7 @@ const VideoWidget$4 = forwardRef(({ rec, index, height, data, muted, activeIndex
17976
17981
  };
17977
17982
  }, [handleClickVideo, isActive]);
17978
17983
  const renderPoster = useMemo(() => {
17979
- var _a, _b;
17980
- 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) {
17984
+ if (!videoPoster || isLoadFinish) {
17981
17985
  return null;
17982
17986
  }
17983
17987
  return (React.createElement("img", { style: {
@@ -17987,8 +17991,8 @@ const VideoWidget$4 = forwardRef(({ rec, index, height, data, muted, activeIndex
17987
17991
  width: '100%',
17988
17992
  height: '100%',
17989
17993
  objectFit: 'cover'
17990
- }, src: ((_b = rec === null || rec === void 0 ? void 0 : rec.video) === null || _b === void 0 ? void 0 : _b.cover) || (sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image), alt: 'placeholder image' }));
17991
- }, [rec, isLoadFinish, sxpParameter === null || sxpParameter === void 0 ? void 0 : sxpParameter.placeholder_image]);
17994
+ }, src: videoPoster, alt: 'placeholder image' }));
17995
+ }, [isLoadFinish]);
17992
17996
  const renderLoading = useMemo(() => {
17993
17997
  if (!waiting || !isLoadFinish)
17994
17998
  return;
@@ -18008,8 +18012,7 @@ const VideoWidget$4 = forwardRef(({ rec, index, height, data, muted, activeIndex
18008
18012
  if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
18009
18013
  return;
18010
18014
  const handleBeforeUnload = () => {
18011
- var _a;
18012
- 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) {
18015
+ if (activeIndex === index && videoUrl && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) && !isPauseVideo) {
18013
18016
  handleClickVideo('pause')();
18014
18017
  }
18015
18018
  };