在reactjs视频组件中捕获MediaStream

问题描述

我想从反应视频组件捕获本地视频MediaStream对象,并将其传递到WebRTC。 captureStream()方法可能不在React中,有人可以分享给我这个代码吗?

当我尝试在React中运行 captureStream()时,它向我显示错误(captureStream不存在于reactjs中)

解决方法

 <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();