@halibegic/react-video-player 0.0.14 → 0.0.15
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.
|
@@ -281,7 +281,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[wt]+=1);function ns({children
|
|
|
281
281
|
&::before {
|
|
282
282
|
content: "/";
|
|
283
283
|
}
|
|
284
|
-
`;function Os(){const[e,t]=p.useState(0),[n,r]=p.useState(0),s=m(f=>f.isPlaying),a=B(f=>f.delay),l=B(f=>f.startTime),c=B(f=>f.endTime),u=p.useCallback(()=>{t(Kn(l,a)),r(Qn(l,c))},[a,c,l]);return et(()=>u(),s?1e3:null),p.useEffect(()=>{u()},[u]),a?i.jsxs(nr,{children:[i.jsx(or,{children:Fe(e)}),i.jsx(ir,{}),i.jsx(sr,{children:Fe(n)})]}):null}function As(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M22 12C22 17.5228 17.5229 22 12 22C6.4772 22 2 17.5228 2 12C2 6.47715 6.4772 2 12 2V4C7.5817 4 4 7.58172 4 12C4 16.4183 7.5817 20 12 20C16.4183 20 20 16.4183 20 12C20 9.53614 18.8862 7.33243 17.1346 5.86492L15 8V2L21 2L18.5535 4.44656C20.6649 6.28002 22 8.9841 22 12Z"})})}function Fs(){const e=B(r=>r.startTime),t=B(r=>r.setDelay),n=()=>t(Jn(e));return i.jsx(me,{onClick:n,children:i.jsx(As,{})})}function Ms({url:e,isLive:t}){const n=p.useRef(null),r=m(b=>b.level),s=m(b=>b.levels),a=m(b=>b.setLevel),l=m(b=>b.setLevels),c=m(b=>b.techRef),u=m(b=>b.isStarted),[f,h]=p.useState(!1),g=p.useCallback(b=>{if(n.current&&(n.current.nextLevel=b,a(null),s)){const S=s.map(w=>({...w,selected:w.value===b}));l(S)}},[s,a,l,n]),x=p.useCallback(()=>{n.current&&(console.log("[Player][HLS] MEDIA_ATTACHED"),n.current.loadSource(e))},[e]),C=p.useCallback(()=>{if(!n.current)return;console.log("[Player][HLS] MANIFEST_LOADED");const b=n.current.levels,S=n.current.currentLevel,w=n.current.autoLevelEnabled;l(_s({levels:b.map((v,D)=>{const{bitrate:R,height:k,width:W}=v;return{bitrate:R,height:k,index:D,width:W}}),level:S,isAuto:w}))},[l]),T=p.useCallback((b,S)=>{console.error("[Player][HLS] ERROR",b,S),f?
|
|
284
|
+
`;function Os(){const[e,t]=p.useState(0),[n,r]=p.useState(0),s=m(f=>f.isPlaying),a=B(f=>f.delay),l=B(f=>f.startTime),c=B(f=>f.endTime),u=p.useCallback(()=>{t(Kn(l,a)),r(Qn(l,c))},[a,c,l]);return et(()=>u(),s?1e3:null),p.useEffect(()=>{u()},[u]),a?i.jsxs(nr,{children:[i.jsx(or,{children:Fe(e)}),i.jsx(ir,{}),i.jsx(sr,{children:Fe(n)})]}):null}function As(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M22 12C22 17.5228 17.5229 22 12 22C6.4772 22 2 17.5228 2 12C2 6.47715 6.4772 2 12 2V4C7.5817 4 4 7.58172 4 12C4 16.4183 7.5817 20 12 20C16.4183 20 20 16.4183 20 12C20 9.53614 18.8862 7.33243 17.1346 5.86492L15 8V2L21 2L18.5535 4.44656C20.6649 6.28002 22 8.9841 22 12Z"})})}function Fs(){const e=B(r=>r.startTime),t=B(r=>r.setDelay),n=()=>t(Jn(e));return i.jsx(me,{onClick:n,children:i.jsx(As,{})})}function Ms({url:e,isLive:t}){const n=p.useRef(null),r=m(b=>b.level),s=m(b=>b.levels),a=m(b=>b.setLevel),l=m(b=>b.setLevels),c=m(b=>b.techRef),u=m(b=>b.isStarted),[f,h]=p.useState(!1),g=p.useCallback(b=>{if(n.current&&(n.current.nextLevel=b,a(null),s)){const S=s.map(w=>({...w,selected:w.value===b}));l(S)}},[s,a,l,n]),x=p.useCallback(()=>{n.current&&(console.log("[Player][HLS] MEDIA_ATTACHED"),n.current.loadSource(e))},[e]),C=p.useCallback(()=>{if(!n.current)return;console.log("[Player][HLS] MANIFEST_LOADED");const b=n.current.levels,S=n.current.currentLevel,w=n.current.autoLevelEnabled;l(_s({levels:b.map((v,D)=>{const{bitrate:R,height:k,width:W}=v;return{bitrate:R,height:k,index:D,width:W}}),level:S,isAuto:w}))},[l]),T=p.useCallback((b,S)=>{console.error("[Player][HLS] ERROR",b,S),t&&!f?(console.log("[Player][HLS] Stream failed, attempting failover retry..."),h(!0),setTimeout(()=>{if(n.current&&c.current)try{console.log("[Player][HLS] Retrying stream..."),n.current.loadSource(e)}catch(w){console.error("[Player][HLS] Failover retry failed:",w)}},1e3)):console.error("[Player][HLS] Stream failed and retry limit reached")},[t,f,c,e]),L=p.useCallback(()=>{if(!c.current)return;const w=t?{backBufferLength:10,startLevel:-1}:{backBufferLength:60,startLevel:-1};try{console.log("[Player][HLS] URL",e),console.log("[Player][HLS] Config",JSON.stringify(w)),console.log("[Player][HLS] Version",ue.version),n.current=new ue(w),n.current.attachMedia(c.current),n.current.on(ue.Events.MEDIA_ATTACHED,x),n.current.on(ue.Events.MANIFEST_LOADED,C),n.current.on(ue.Events.ERROR,T)}catch(v){throw new Error(`Error initializing Hls: ${v}`)}},[C,x,T,t,c,e]),N=p.useCallback(()=>{n.current&&(n.current.off(ue.Events.MEDIA_ATTACHED,x),n.current.off(ue.Events.MANIFEST_LOADED,C),n.current.off(ue.Events.ERROR,T),n.current.destroy(),n.current=null),h(!1)},[C,x,T]);return p.useEffect(()=>{r!==null&&g(r)},[r,g]),p.useEffect(()=>{u&&h(!1)},[u]),p.useEffect(()=>(ue.isSupported()&&L(),N),[N,L]),null}function ar({url:e,isLive:t,isMuted:n=!1}){const r=m(v=>v.handleDurationChange),s=m(v=>v.handleEnd),a=m(v=>v.handleLoadedMetadata),l=m(v=>v.handleLoadStart),c=m(v=>v.handlePause),u=m(v=>v.handlePlay),f=m(v=>v.handlePlaying),h=m(v=>v.handleSeeked),g=m(v=>v.handleSeeking),x=m(v=>v.handleTimeUpdate),C=m(v=>v.handleWaiting),T=m(v=>v.techRef),L=p.useRef(null),N=v=>{console.error("[Player][Native] ERROR",v)},b=()=>t?{}:{onDurationChange:r,onSeeked:h,onSeeking:g,onTimeUpdate:S},S=()=>{(!L.current||Date.now()-L.current>=1e3)&&(x(),L.current=Date.now())},w=b();return i.jsxs(i.Fragment,{children:[i.jsx(Ms,{isLive:t,url:e}),i.jsx(Vs,{ref:T,playsInline:!0,autoPlay:!0,controls:!1,muted:n,preload:"auto",crossOrigin:"anonymous",onEnded:s,onError:N,onLoadedMetadata:a,onLoadStart:l,onPause:c,onPlay:u,onPlaying:f,onWaiting:C,tabIndex:-1,...w})]})}const Vs=I.video`
|
|
285
285
|
position: relative;
|
|
286
286
|
width: 100%;
|
|
287
287
|
height: 100%;
|
|
@@ -289,7 +289,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[wt]+=1);function ns({children
|
|
|
289
289
|
@media (min-width: 768px) {
|
|
290
290
|
pointer-events: none;
|
|
291
291
|
}
|
|
292
|
-
`;function Ns({url:e}){const[t,n]=p.useState(null),r=B(a=>a.delay),s=p.useCallback(async()=>{n(r?e.replace("playlist.m3u8",`playlist_fmp4_dvr_timeshift-${r}.m3u8`):e)},[r,e]);return p.useEffect(()=>{s()},[s]),t?i.jsx(ar,{url:t,isLive:!0}):null}const cr=I.div`
|
|
292
|
+
`;function Ns({url:e}){const[t,n]=p.useState(null),r=B(a=>a.delay),s=p.useCallback(async()=>{n(r?e.replace("-live","-catchup").replace("playlist.m3u8",`playlist_fmp4_dvr_timeshift-${r}.m3u8`):e)},[r,e]);return p.useEffect(()=>{s()},[s]),t?i.jsx(ar,{url:t,isLive:!0}):null}const cr=I.div`
|
|
293
293
|
position: absolute;
|
|
294
294
|
top: 0;
|
|
295
295
|
left: 0;
|