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/pb-ui.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash'), require('uuid'), require('pako'), require('react'), require('qs'), require('@emotion/css'), require('@ant-design/pro-components'), require('react-dom'), require('hls.js'), require('eventemitter3')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'lodash', 'uuid', 'pako', 'react', 'qs', '@emotion/css', '@ant-design/pro-components', 'react-dom', 'hls.js', 'eventemitter3'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.PUI = {}, global.lodash, global.uuid$1, global.pako, global.React, global.qs, global.css, global.proComponents, global.ReactDOM, global.Hls, global.EventEmitter));
5
- })(this, (function (exports, lodash, uuid$1, pako, React, qs, css, proComponents, ReactDOM, Hls, EventEmitter) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash'), require('uuid'), require('pako'), require('react'), require('qs'), require('@emotion/css'), require('@ant-design/pro-components'), require('react-dom'), require('eventemitter3')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'lodash', 'uuid', 'pako', 'react', 'qs', '@emotion/css', '@ant-design/pro-components', 'react-dom', 'eventemitter3'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.PUI = {}, global.lodash, global.uuid$1, global.pako, global.React, global.qs, global.css, global.proComponents, global.ReactDOM, global.EventEmitter));
5
+ })(this, (function (exports, lodash, uuid$1, pako, React, qs, css, proComponents, ReactDOM, EventEmitter) { 'use strict';
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  var n = Object.create(null);
@@ -11992,12 +11992,13 @@ Made in Italy` })));
11992
11992
  const { isActive } = useSwiperSlide();
11993
11993
  const canvasRef = React.useRef(null);
11994
11994
  const [firstFrameSrc, setFirstFrameSrc] = React.useState('');
11995
+ const videoId = `pb-video-${index}`;
11995
11996
  React.useEffect(() => {
11996
11997
  if (!videoRef.current)
11997
11998
  return;
11998
- videoRef.current.muted = muted;
11999
+ videoRef.current.muted(muted);
11999
12000
  }, [muted]);
12000
- const handleVideoStart = React.useCallback(() => {
12001
+ const handleEnded = React.useCallback(() => {
12001
12002
  var _a;
12002
12003
  (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
12003
12004
  }, []);
@@ -12006,10 +12007,10 @@ Made in Italy` })));
12006
12007
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
12007
12008
  setIsPauseVideo(false);
12008
12009
  const item = data[index];
12009
- if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
12010
- videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
12011
- const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
12012
- const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
12010
+ if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration())) {
12011
+ videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime()) || 0;
12012
+ const videoDuration = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.duration()) !== null && _d !== void 0 ? _d : 0).toFixed(2);
12013
+ const videoCurrentTime = ((_f = (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime()) !== null && _f !== void 0 ? _f : 0).toFixed(2);
12013
12014
  const playType = isFirstPlay ? '0' : '1';
12014
12015
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
12015
12016
  eventInfo: {
@@ -12029,14 +12030,14 @@ Made in Italy` })));
12029
12030
  setIsFirstPlay(false);
12030
12031
  }
12031
12032
  }, [bffEventReport, data, index, isFirstPlay]);
12032
- const handleLoadedMetadata = React.useCallback(() => {
12033
+ const handleCanplay = React.useCallback(() => {
12033
12034
  setIsLoadFinish(true);
12034
12035
  }, []);
12035
12036
  const handleClickVideo = React.useCallback((type) => () => {
12036
12037
  var _a, _b, _c, _d, _e;
12037
12038
  if (!isLoadFinish)
12038
12039
  return;
12039
- const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
12040
+ const isPause = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.paused();
12040
12041
  switch (type) {
12041
12042
  case 'start':
12042
12043
  if (!isPause)
@@ -12061,13 +12062,13 @@ Made in Italy` })));
12061
12062
  break;
12062
12063
  }
12063
12064
  }, [isLoadFinish]);
12064
- const onPause = React.useCallback(() => {
12065
+ const handlePause = React.useCallback(() => {
12065
12066
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
12066
12067
  const item = data[index];
12067
- const videoDuration = ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
12068
- const videoCurrentTime = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
12069
- if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
12070
- const playDuration = (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
12068
+ const videoDuration = ((_b = (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.duration()) !== null && _b !== void 0 ? _b : 0).toFixed(2);
12069
+ const videoCurrentTime = ((_d = (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime()) !== null && _d !== void 0 ? _d : 0).toFixed(2);
12070
+ if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration()) {
12071
+ const playDuration = (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime()) - videoStartTime.current).toFixed(2);
12071
12072
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
12072
12073
  eventInfo: {
12073
12074
  eventSubject: 'playOverVideo',
@@ -12099,9 +12100,10 @@ Made in Italy` })));
12099
12100
  return ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || firstFrameSrc;
12100
12101
  }, [firstFrameSrc, rec]);
12101
12102
  const handLoadeddata = React.useCallback(() => {
12102
- if (!canvasRef || !videoRef || !videoRef.current || !canvasRef.current)
12103
+ const videoDomRef = document.getElementById(`${videoId}_html5_api`);
12104
+ if (!canvasRef || !videoDomRef || !canvasRef.current)
12103
12105
  return;
12104
- const video = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current;
12106
+ const video = videoDomRef;
12105
12107
  const canvas = canvasRef === null || canvasRef === void 0 ? void 0 : canvasRef.current;
12106
12108
  const ctx = canvas.getContext('2d');
12107
12109
  const targetWidth = window === null || window === void 0 ? void 0 : window.innerWidth;
@@ -12112,43 +12114,35 @@ Made in Italy` })));
12112
12114
  setFirstFrameSrc(canvas.toDataURL());
12113
12115
  }, []);
12114
12116
  React.useEffect(() => {
12115
- var _a, _b, _c, _d;
12116
- if (!videoRef.current)
12117
+ var _a, _b, _c, _d, _e, _f;
12118
+ if (videoRef.current)
12117
12119
  return;
12118
12120
  setIsPauseVideo(false);
12119
- if (!videoRef.current.src) {
12120
- const videoSrc = rec.video.url;
12121
- if (videoSrc.includes('.m3u8')) {
12122
- if (Hls.isSupported()) {
12123
- const hls = new Hls();
12124
- hls.loadSource(videoSrc);
12125
- hls.attachMedia(videoRef.current);
12126
- }
12127
- else if (videoRef.current.canPlayType('application/vnd.apple.mpegurl')) {
12128
- videoRef.current.src = videoSrc;
12129
- }
12130
- else {
12131
- videoRef.current.src = videoSrc;
12132
- }
12133
- }
12134
- else {
12135
- videoRef.current.src = videoSrc;
12136
- }
12137
- videoRef.current.setAttribute('x5-playsinline', 'true');
12138
- videoRef.current.setAttribute('webkit-playsinline', 'true');
12121
+ const videoSrc = rec.video.url;
12122
+ if (videoSrc && typeof TCPlayer === 'function') {
12123
+ videoRef.current = TCPlayer(videoId, {
12124
+ sources: [
12125
+ {
12126
+ src: videoSrc // 播放地址
12127
+ }
12128
+ ],
12129
+ licenseUrl: 'https://license.vod2.myqcloud.com/license/v2/1325816236_1/v_cube.license', // license 地址,参考准备工作部分,在视立方控制台申请 license 后可获得 licenseUrl
12130
+ controls: false,
12131
+ autoplay: false,
12132
+ loop: false,
12133
+ muted: true,
12134
+ preload: 'meta',
12135
+ posterImage: false,
12136
+ bigPlayButton: true
12137
+ });
12139
12138
  }
12140
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('loadedmetadata', handleLoadedMetadata);
12141
- (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.addEventListener('canplay', handleLoadedMetadata);
12142
- (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('playing', handlePlaying);
12143
- (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('loadeddata', handLoadeddata);
12144
- return () => {
12145
- var _a, _b, _c, _d;
12146
- (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('loadedmetadata', handleLoadedMetadata);
12147
- (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('canplay', handleLoadedMetadata);
12148
- (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('playing', handlePlaying);
12149
- (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('loadeddata', handLoadeddata);
12150
- };
12151
- }, [handleLoadedMetadata, handlePlaying, rec.video, handLoadeddata]);
12139
+ (_a = videoRef.current) === null || _a === void 0 ? void 0 : _a.on('loadedmetadata', handleCanplay);
12140
+ (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.on('canplay', handleCanplay);
12141
+ (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.on('playing', handlePlaying);
12142
+ (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.on('loadeddata', handLoadeddata);
12143
+ (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.on('pause', handlePause);
12144
+ (_f = videoRef.current) === null || _f === void 0 ? void 0 : _f.on('ended', handleEnded);
12145
+ }, [handleCanplay, handlePlaying, rec.video, handLoadeddata, index, handlePause, handleEnded, videoId]);
12152
12146
  React.useEffect(() => {
12153
12147
  var _a;
12154
12148
  if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
@@ -12234,19 +12228,27 @@ Made in Italy` })));
12234
12228
  right: 0
12235
12229
  } },
12236
12230
  React.createElement("div", { style: { position: 'relative', width: '100%', height: '100%' } },
12237
- 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: {
12231
+ React.createElement("video", { id: `pb-video-${index}`, playsInline: true, crossOrigin: 'anonymous', style: {
12238
12232
  width: '100%',
12239
12233
  height: '100%',
12240
- objectFit: 'contain'
12234
+ objectFit: 'contain',
12235
+ backgroundColor: 'transparent',
12236
+ pointerEvents: 'none'
12241
12237
  } }),
12242
12238
  React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON }))),
12243
- renderPoster)) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, onClick: handleClickVideo(), style: {
12239
+ renderPoster)) : (React.createElement("div", { className: 'video-container', key: rec.video.itemId, style: {
12244
12240
  position: 'relative',
12245
12241
  width: '100%',
12246
12242
  height,
12247
12243
  overflow: 'hidden'
12248
- } },
12249
- 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 }),
12244
+ }, onClick: handleClickVideo() },
12245
+ React.createElement("video", { id: `pb-video-${index}`, playsInline: true, crossOrigin: 'anonymous', style: {
12246
+ backgroundColor: 'transparent',
12247
+ width: '100%',
12248
+ height: '100%',
12249
+ objectFit: 'cover',
12250
+ pointerEvents: 'none'
12251
+ } }),
12250
12252
  renderPoster,
12251
12253
  React.createElement("img", { hidden: !isPauseVideo, className: 'clc-pb-video-pause', src: PAUSE_ICON })))));
12252
12254
  };