Loading
function(e,t,n){n.d(t,{Ay:()=>c,Bu:()=>s,OJ:()=>u,XY:()=>o});var r=n(582128),l=n(876230),i=n(614269),a=n(53200);let o=8e5,u=20,s=30;function c(e,t){let{src:n,initialTimeSec:c=0,onError:d,onHlsInstance:m,crossOrigin:f="anonymous"}=t,p=r.useRef(null),[h,x]=r.useState(null),v=r.useRef(c);v.current=c;let g=r.useRef(d),E=r.useRef(m),b=r.useRef(f);b.current=f,r.useEffect(()=>{g.current=d},[d]),r.useEffect(()=>{E.current=m},[m]);let[y,P]=r.useState(!1),S=!y&&i.u.isHlsUrl(n)&&(0,a.Ap)();return r.useEffect(()=>{if(!S||null==n||null==e.current)return;let t=e.current,r=!1,i=null,c=null;return(0,a.E)().then(e=>{if(r)return;if(!e.isSupported())return void P(!0);let a=i=new e({backBufferLength:u,maxBufferLength:s,startPosition:v.current,startFragPrefetch:!0,startLevel:-1,xhrSetup:e=>{e.withCredentials="use-credentials"===b.current},fetchSetup:(e,t)=>(t.credentials=function(e){switch(e){case"use-credentials":return"include";case"anonymous":case null:return"same-origin"}}(b.current),new Request(e.url,t))});p.current=a,x(a),E.current?.(a);let d=0;c=()=>{a.mainForwardBufferInfo?.len===0&&a.trigger(e.Events.BUFFER_FLUSHING,{startOffset:t.currentTime,endOffset:1/0,type:"video"})},a.on(e.Events.FRAG_LOADING,function(){a.config.minAutoBitrate!==o&&(a.config.minAutoBitrate=o)}),a.on(e.Events.ERROR,function(t,n){if(g.current?.(function(e,t){switch(t){case e.ErrorTypes.NETWORK_ERROR:return l.SB.HLS_NETWORK_ERROR;case e.ErrorTypes.MEDIA_ERROR:return l.SB.HLS_MEDIA_ERROR;case e.ErrorTypes.MUX_ERROR:return l.SB.HLS_MUX_ERROR;case e.ErrorTypes.KEY_SYSTEM_ERROR:return l.SB.HLS_KEY_SYSTEM_ERROR;default:return l.SB.HLS_OTHER_ERROR}}(e,n.type),{errorDetails:n.details,fatal:n.fatal}),n.fatal){if(d>=3){a.destroy(),p.current=null,x(null),E.current?.(null);return}switch(d++,n.type){case e.ErrorTypes.NETWORK_ERROR:a.startLoad();break;case e.ErrorTypes.MEDIA_ERROR:a.recoverMediaError();break;default:a.destroy(),p.current=null,E.current?.(null)}}}),t.addEventListener("seeking",c),a.loadSource(n),a.attachMedia(t)}),()=>{r=!0,null!=c&&t.removeEventListener("seeking",c),null!=i&&(p.current===i&&(i.destroy(),p.current=null,x(null),E.current?.(null)),t.removeAttribute("src"),t.load())}},[S,n,e]),{isHlsActive:S,hlsRef:p,hls:h}}}