"use strict";(this.webpackChunk_lingxiteam_pcfactory=this.webpackChunk_lingxiteam_pcfactory||[]).push([[682],{65690:function(e,t,n){n.r(t);var r=n(7896),o=n(32723),a=n(34795),i=n(31461),u=n(90359),l=n.n(u),s=n(80960),c=n(23716),d=["style","volume","fileCode","playing","url","streamType","videoCode","playbackRate","speed","getEngineApis","onReady","onStart","onPlay","onPause","onProgress","onError","onDuration"],f=["width","height"],p=function(e,t){var n=e.style,p=e.volume,v=void 0===p?100:p,y=e.fileCode,h=e.playing,g=e.url,m=e.streamType,E=e.videoCode,k=e.playbackRate,w=e.speed,P=e.getEngineApis,b=e.onReady,C=e.onStart,R=e.onPlay,Z=e.onPause,x=e.onProgress,S=e.onError,A=e.onDuration,F=(0,i.Z)(e,d),_=(null==P?void 0:P())||{},D=n||{},N=D.width,B=D.height,M=(0,i.Z)(D,f),T=(0,u.useState)(),U=T[0],W=T[1],V=(0,u.useState)(!1),j=V[0],q=V[1],z=(0,u.useRef)(),G=(0,u.useState)(h),H=G[0],I=G[1],J=(0,u.useState)(""),K=J[0],L=J[1],O=(0,u.useRef)(),Q=(0,u.useMemo)((function(){return w&&"number"==typeof k&&k&&k>0?k:1}),[k,w]);(0,u.useEffect)((function(){I(h)}),[h]);var X=(0,u.useMemo)((function(){return isNaN(v)?1:v/100}),[v]);return(0,u.useEffect)((function(){var e;if(!B&&null!=z&&null!==(e=z.current)&&void 0!==e&&e.offsetWidth){var t,n=(null==z||null===(t=z.current)||void 0===t?void 0:t.offsetWidth)/16*9;W(n)}else W(B)}),[B]),(0,u.useEffect)((function(){y?(0,a.Z)((0,o.Z)().mark((function e(){var t;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.t0=q,e.next=4,null==_||null===(t=_.service)||void 0===t?void 0:t.getAppFileUrlByFileCode(y);case 4:e.t1=e.sent,(0,e.t0)(e.t1),e.next=11;break;case 8:e.prev=8,e.t2=e.catch(0),c.log("获取视频封面出错:".concat(e.t2));case 11:case"end":return e.stop()}}),e,null,[[0,8]])})))():q(!1)}),[y]),(0,u.useEffect)((function(){"fileCode"===m?E?(0,a.Z)((0,o.Z)().mark((function e(){var t;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.t0=L,e.next=4,null==_||null===(t=_.service)||void 0===t?void 0:t.getAppFileUrlByFileCode(E);case 4:e.t1=e.sent,(0,e.t0)(e.t1),e.next=11;break;case 8:e.prev=8,e.t2=e.catch(0),c.log("获取视频资源出错:".concat(e.t2));case 11:case"end":return e.stop()}}),e,null,[[0,8]])})))():L(""):L(g)}),[m,E,g]),l().createElement("div",{ref:z,style:{width:"100%",height:U,borderRadius:(null==n?void 0:n.borderRadius)||"0px"}},l().createElement(s.Z,(0,r.Z)({width:N||"100%",height:U||"100%",style:M,volume:X,light:j,playing:H,playbackRate:Q,onClickPreview:function(){I(!0)},onEnded:function(){h||I(!1),null!=e&&e.onEnded&&(null==e||e.onEnded(O.current))},url:K,onReady:b,onStart:C,onPlay:R,onPause:Z,onProgress:x,onError:S,onDuration:function(e){O.current=e,A&&A(e)}},F)))};p.displayName="VideoPlayer",t.default=p}}]);