pb-sxp-ui 1.0.31 → 1.0.33

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.css CHANGED
@@ -1413,12 +1413,6 @@ button.swiper-pagination-bullet {
1413
1413
  -webkit-transform: translate3d(0px, 0px, 0px);
1414
1414
  transform: translate3d(0px, 0px, 0px);
1415
1415
  }
1416
- .video-container video {
1417
- width: 100%;
1418
- height: 100%;
1419
- -o-object-fit: cover;
1420
- object-fit: cover;
1421
- }
1422
1416
  .modal-bg {
1423
1417
  position: fixed;
1424
1418
  left: 0;
package/dist/index.js CHANGED
@@ -6,7 +6,6 @@ import qs from 'qs';
6
6
  import { css } from '@emotion/css';
7
7
  import { BetaSchemaForm } from '@ant-design/pro-components';
8
8
  import * as ReactDOM from 'react-dom';
9
- import Hls from 'hls.js';
10
9
  import EventEmitter from 'eventemitter3';
11
10
 
12
11
  /******************************************************************************
@@ -11978,12 +11977,13 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
11978
11977
  const { isActive } = useSwiperSlide();
11979
11978
  const canvasRef = useRef(null);
11980
11979
  const [firstFrameSrc, setFirstFrameSrc] = useState('');
11980
+ const videoId = `pb-video-${index}`;
11981
11981
  useEffect(() => {
11982
11982
  if (!videoRef.current)
11983
11983
  return;
11984
- videoRef.current.muted = muted;
11984
+ videoRef.current.muted(muted);
11985
11985
  }, [muted]);
11986
- const handleVideoStart = useCallback(() => {
11986
+ const handleEnded = useCallback(() => {
11987
11987
  var _a;
11988
11988
  (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
11989
11989
  }, []);
@@ -11992,10 +11992,10 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
11992
11992
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
11993
11993
  setIsPauseVideo(false);
11994
11994
  const item = data[index];
11995
- if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
11996
- videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
11997
- const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
11998
- const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
11995
+ if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration())) {
11996
+ videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime()) || 0;
11997
+ const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration()) !== null && _d !== void 0 ? _d : 0).toFixed(2);
11998
+ const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime()) !== null && _f !== void 0 ? _f : 0).toFixed(2);
11999
11999
  const playType = isFirstPlay ? '0' : '1';
12000
12000
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
12001
12001
  eventInfo: {
@@ -12015,14 +12015,14 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
12015
12015
  setIsFirstPlay(false);
12016
12016
  }
12017
12017
  }, [bffEventReport, data, index, isFirstPlay]);
12018
- const handleLoadedMetadata = useCallback(() => {
12018
+ const handleCanplay = useCallback(() => {
12019
12019
  setIsLoadFinish(true);
12020
12020
  }, []);
12021
12021
  const handleClickVideo = useCallback((type) => () => {
12022
12022
  var _a, _b, _c, _d, _e;
12023
12023
  if (!isLoadFinish)
12024
12024
  return;
12025
- const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
12025
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused();
12026
12026
  switch (type) {
12027
12027
  case 'start':
12028
12028
  if (!isPause)
@@ -12047,13 +12047,13 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
12047
12047
  break;
12048
12048
  }
12049
12049
  }, [isLoadFinish]);
12050
- const onPause = useCallback(() => {
12050
+ const handlePause = useCallback(() => {
12051
12051
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
12052
12052
  const item = data[index];
12053
- const videoDuration = ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
12054
- const videoCurrentTime = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
12055
- if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
12056
- const playDuration = (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
12053
+ const videoDuration = ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration()) !== null && _b !== void 0 ? _b : 0).toFixed(2);
12054
+ const videoCurrentTime = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime()) !== null && _d !== void 0 ? _d : 0).toFixed(2);
12055
+ if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration()) {
12056
+ const playDuration = (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime()) - videoStartTime.current).toFixed(2);
12057
12057
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
12058
12058
  eventInfo: {
12059
12059
  eventSubject: 'playOverVideo',
@@ -12085,9 +12085,10 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
12085
12085
  return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
12086
12086
  }, [firstFrameSrc, rec]);
12087
12087
  const handLoadeddata = useCallback(() => {
12088
- if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
12088
+ const videoDomRef = document.getElementById(`${videoId}_html5_api`);
12089
+ if (!canvasRef || !videoDomRef || !canvasRef.current)
12089
12090
  return;
12090
- const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
12091
+ const video = videoDomRef;
12091
12092
  const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
12092
12093
  const ctx = canvas.getContext('2d');
12093
12094
  const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
@@ -12098,43 +12099,35 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
12098
12099
  setFirstFrameSrc(canvas.toDataURL());
12099
12100
  }, []);
12100
12101
  useEffect(() => {
12101
- var _a, _b, _c, _d;
12102
- if (!videoRef.current)
12102
+ var _a, _b, _c, _d, _e, _f;
12103
+ if (videoRef.current)
12103
12104
  return;
12104
12105
  setIsPauseVideo(false);
12105
- if (!videoRef.current.src) {
12106
- const videoSrc = rec.video.url;
12107
- if (videoSrc.includes('.m3u8')) {
12108
- if (Hls.isSupported()) {
12109
- const hls = new Hls();
12110
- hls.loadSource(videoSrc);
12111
- hls.attachMedia(videoRef.current);
12112
- }
12113
- else if (videoRef.current.canPlayType('application/vnd.apple.mpegurl')) {
12114
- videoRef.current.src = videoSrc;
12115
- }
12116
- else {
12117
- videoRef.current.src = videoSrc;
12118
- }
12119
- }
12120
- else {
12121
- videoRef.current.src = videoSrc;
12122
- }
12123
- videoRef.current.setAttribute('x5-playsinline', 'true');
12124
- videoRef.current.setAttribute('webkit-playsinline', 'true');
12106
+ const videoSrc = rec.video.url;
12107
+ if (videoSrc && typeof TCPlayer === 'function') {
12108
+ videoRef.current = TCPlayer(videoId, {
12109
+ sources: [
12110
+ {
12111
+ src: videoSrc // 播放地址
12112
+ }
12113
+ ],
12114
+ licenseUrl: 'https://license.vod2.myqcloud.com/license/v2/1325816236_1/v_cube.license', // license 地址,参考准备工作部分,在视立方控制台申请 license 后可获得 licenseUrl
12115
+ controls: false,
12116
+ autoplay: false,
12117
+ loop: false,
12118
+ muted: true,
12119
+ preload: 'meta',
12120
+ posterImage: false,
12121
+ bigPlayButton: true
12122
+ });
12125
12123
  }
12126
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
12127
- (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('canplay', handleLoadedMetadata);
12128
- (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('playing', handlePlaying);
12129
- (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('loadeddata', handLoadeddata);
12130
- return () => {
12131
- var _a, _b, _c, _d;
12132
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('loadedmetadata', handleLoadedMetadata);
12133
- (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('canplay', handleLoadedMetadata);
12134
- (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('playing', handlePlaying);
12135
- (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('loadeddata', handLoadeddata);
12136
- };
12137
- }, [handleLoadedMetadata, handlePlaying, rec.video, handLoadeddata]);
12124
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.on('loadedmetadata', handleCanplay);
12125
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.on('canplay', handleCanplay);
12126
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.on('playing', handlePlaying);
12127
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.on('loadeddata', handLoadeddata);
12128
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.on('pause', handlePause);
12129
+ (_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.on('ended', handleEnded);
12130
+ }, [handleCanplay, handlePlaying, rec.video, handLoadeddata, index, handlePause, handleEnded, videoId]);
12138
12131
  useEffect(() => {
12139
12132
  var _a;
12140
12133
  if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
@@ -12220,19 +12213,27 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
12220
12213
  right: 0
12221
12214
  } },
12222
12215
  React.createElement("div", { style: { position: 'relative', width: '100%', height: '100%' } },
12223
- React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, crossOrigin: 'anonymous', muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart, style: {
12216
+ React.createElement("video", { id: `pb-video-${index}`, playsInline: true, crossOrigin: 'anonymous', style: {
12224
12217
  width: '100%',
12225
12218
  height: '100%',
12226
- objectFit: 'contain'
12219
+ objectFit: 'contain',
12220
+ backgroundColor: 'transparent',
12221
+ pointerEvents: 'none'
12227
12222
  } }),
12228
12223
  React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON }))),
12229
- renderPoster)) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
12224
+ renderPoster)) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, style: {
12230
12225
  position: 'relative',
12231
12226
  width: '100%',
12232
12227
  height,
12233
12228
  overflow: 'hidden'
12234
- } },
12235
- React.createElement("video", { id: `pb-video-${index}`, className: 'clc-pb-video', ref: videoRef, crossOrigin: 'anonymous', muted: true, controls: false, playsInline: true, preload: 'auto', onPause: onPause, onEnded: handleVideoStart }),
12229
+ }, onClick: handleClickVideo() },
12230
+ React.createElement("video", { id: `pb-video-${index}`, playsInline: true, crossOrigin: 'anonymous', style: {
12231
+ backgroundColor: 'transparent',
12232
+ width: '100%',
12233
+ height: '100%',
12234
+ objectFit: 'cover',
12235
+ pointerEvents: 'none'
12236
+ } }),
12236
12237
  renderPoster,
12237
12238
  React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })))));
12238
12239
  };