@@ -5,6 +5,7 @@ import videojs from "video.js";
55
66interface  PlayerProps  { 
77  videoSrc : string ; 
8+   mimeType ?: string ; 
89} 
910
1011const  videoJSoptions : { 
@@ -31,28 +32,10 @@ export const VideoRenderer = (props: PlayerProps) => {
3132  const  playerRef  =  React . useRef < any > ( null ) ; 
3233
3334  const  [ videoSrc ,  setVideoSrc ]  =  React . useState < string  |  undefined > ( ) ; 
34-   const  [ overrideMimeType ,  setOverrideMimeType ]  =  React . useState < 
35-     string  |  undefined 
36-   > ( undefined ) ; 
3735
3836  const  [ hasStartedPlaying ,  setHasStartedPlaying ]  = 
3937    React . useState < boolean > ( false ) ; 
4038
41-   const  pollUrl  =  useCallback ( 
42-     async  ( url : string )  =>  { 
43-       const  res  =  await  fetch ( url ,  {  method : "HEAD"  } ) ; 
44-       if  ( hasStartedPlaying )  return ; 
45-       if  ( res . ok )  { 
46-         setVideoSrc ( url ) ; 
47-       }  else  { 
48-         setTimeout ( ( )  =>  { 
49-           pollUrl ( url ) ; 
50-         } ,  1000 ) ; 
51-       } 
52-     } , 
53-     [ setVideoSrc ,  hasStartedPlaying ] 
54-   ) ; 
55- 
5639  const  options  =  useMemo ( 
5740    ( )  =>  ( { 
5841      ...videoJSoptions , 
@@ -61,7 +44,7 @@ export const VideoRenderer = (props: PlayerProps) => {
6144        { 
6245          src : videoSrc  ??  "" , 
6346          type :
64-             overrideMimeType  || 
47+             props . mimeType  || 
6548            ( videoSrc ?. endsWith ( ".m3u8" ) 
6649              ? "application/x-mpegURL" 
6750              : videoSrc ?. endsWith ( ".mp4" ) 
@@ -70,26 +53,12 @@ export const VideoRenderer = (props: PlayerProps) => {
7053        } , 
7154      ] , 
7255    } ) , 
73-     [ videoSrc ,  overrideMimeType ] 
56+     [ videoSrc ,  props . mimeType ] 
7457  ) ; 
7558
7659  useEffect ( ( )  =>  { 
77-     if  ( props . videoSrc . startsWith ( "ipfs://" ) )  { 
78-       // Exchange ipfs:// for .m3u8 url via /livepeer-video?url=ipfs://... 
79-       const  baseUrl  =  `${  
80-         process . env . NEXT_PUBLIC_API_URL  ||  "https://api.modprotocol.org"  
81-       }  /livepeer-video`; 
82-       const  endpointUrl  =  `${ baseUrl }  ?url=${ props . videoSrc }  ` ; 
83-       fetch ( endpointUrl ) . then ( async  ( res )  =>  { 
84-         const  {  url,  fallbackUrl,  mimeType }  =  await  res . json ( ) ; 
85-         setOverrideMimeType ( mimeType ) ; 
86-         setVideoSrc ( `${ fallbackUrl }  ` ) ; 
87-         pollUrl ( url ) ; 
88-       } ) ; 
89-     }  else  { 
90-       setVideoSrc ( props . videoSrc ) ; 
91-     } 
92-   } ,  [ props . videoSrc ,  pollUrl ] ) ; 
60+     setVideoSrc ( props . videoSrc ) ; 
61+   } ,  [ props . videoSrc ] ) ; 
9362
9463  useEffect ( ( )  =>  { 
9564    // Make sure Video.js player is only initialized once 
0 commit comments