Search code examples
reactjswebrtcmediastreamsimplewebrtcrecordrtc

capture MediaStream in reactjs (video component)


I want to capture a local video, MediaStream object from a react video component and pass it into WebRTC. captureStream() method is not present in React may be, can someone share me the code of this???

when i try to run captureStream() in react it shows me error that (captureStream is not present in reactjs)


Solution

  •  <video ref={videoElementRef} muted id="video-element-ids" className="video" /> 
    
    const url = URL.createObjectURL(file);
     this.videoElementRef.current.src = url;
     await this.videoElementRef.current.play();
     const mediaSream = this.videoElementRef.current.captureStream();