我已经实现了 react-webcam 和 react-video-recorder 分别使用设备的网络摄像头拍摄照片和视频。我遵循了文档,它们都在我的本地主机上完美运行。问题是当我部署它们时,浏览器不支持录制视频。我已经在 Chrome、Firefox 和 Opera 上对其进行了测试,但它们都不支持它。
我遵循https://www.npmjs.com/package/react-webcam拍摄图像和https://www.npmjs.com/package/react-video-recorder通过设备的网络摄像头录制视频。
class VideoPost extends Component {
handleRecordingComplete = (videoBlob, startedAt, thumbnailBlob, duration) => {
const urlCreator = window.URL || window.webkitURL;
const videoUrl = urlCreator.createObjectURL(videoBlob);
this.setState({ videoSrc: videoUrl, video: videoBlob });
};
onVideoDisplay = () => (
<video
src={this.state.videoSrc}
controls
style={{
height: '200px',
width: '200px'
}}
/>
);
render(){
return(
<div>
<VideoRecorder
onRecordingComplete={this.handleRecordingComplete}
renderLoadingView={this.onVideoDisplay}
/>
</div>
)
}
}
我错过了什么吗?
这可能是由于来源不安全。确保您已在https上部署您的应用程序,即您已应用有效的 SSL 证书
参考 - react-webcam 的 npm 页面
注意:如果页面是从不安全的来源加载的,浏览器将抛出错误。即使用https。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句