Build 571957stable
Module 718499
2,068 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{Ay:()=>c,Bu:()=>u,OJ:()=>l,XY:()=>o});var i=n(64700),r=n(771253),s=n(876230),a=n(614269);let o=8e5,l=20,u=30;function c(e,t){let{src:n,initialTimeSec:c=0,onError:d,onHlsInstance:_,crossOrigin:h="anonymous"}=t,f=i.useRef(null),p=i.useRef(c);p.current=c;let E=i.useRef(d),m=i.useRef(_),g=i.useRef(h);g.current=h,i.useEffect(()=>{E.current=d},[d]),i.useEffect(()=>{m.current=_},[_]);let A=a.u.isHlsUrl(n)&&r.Ay.isSupported();return i.useEffect(()=>{if(!A||null==n||null==e.current)return;let t=e.current,i=new r.Ay({backBufferLength:l,maxBufferLength:u,startPosition:p.current,startFragPrefetch:!0,startLevel:-1,xhrSetup:e=>{e.withCredentials="use-credentials"===g.current},fetchSetup:(e,t)=>(t.credentials=function(e){switch(e){case"use-credentials":return"include";case"anonymous":case null:return"same-origin"}}(g.current),new Request(e.url,t))});f.current=i,m.current?.(i);let a=0;function c(){i.mainForwardBufferInfo?.len===0&&i.trigger(r.Ay.Events.BUFFER_FLUSHING,{startOffset:t.currentTime,endOffset:1/0,type:"video"})}return i.on(r.Ay.Events.FRAG_LOADING,()=>{i.config.minAutoBitrate!==o&&(i.config.minAutoBitrate=o)}),i.on(r.Ay.Events.ERROR,(e,t)=>{if(E.current?.(function(e){switch(e){case r.Ay.ErrorTypes.NETWORK_ERROR:return s.SB.HLS_NETWORK_ERROR;case r.Ay.ErrorTypes.MEDIA_ERROR:return s.SB.HLS_MEDIA_ERROR;case r.Ay.ErrorTypes.MUX_ERROR:return s.SB.HLS_MUX_ERROR;case r.Ay.ErrorTypes.KEY_SYSTEM_ERROR:return s.SB.HLS_KEY_SYSTEM_ERROR;default:return s.SB.HLS_OTHER_ERROR}}(t.type),{errorDetails:t.details,fatal:t.fatal}),t.fatal){if(a>=3){i.destroy(),f.current=null,m.current?.(null);return}switch(a++,t.type){case r.Ay.ErrorTypes.NETWORK_ERROR:i.startLoad();break;case r.Ay.ErrorTypes.MEDIA_ERROR:i.recoverMediaError();break;default:i.destroy(),f.current=null,m.current?.(null)}}}),t.addEventListener("seeking",c),i.loadSource(n),i.attachMedia(t),()=>{t.removeEventListener("seeking",c),f.current===i&&(i.destroy(),f.current=null,m.current?.(null)),t.removeAttribute("src"),t.load()}},[A,n,e]),{isHlsActive:A,hlsRef:f}}}