【发布时间】:2019-04-12 16:18:43
【问题描述】:
我正在尝试使用 React 钩子在我的应用程序上显示网络摄像头提要。我还需要能够从提要中捕获最新图像
我相信我有基础但缺少一些东西。
import React,{useState,useEffect} from "react"
export function VideoFeed(){
const[constraints] = useState({width:300,height:300})
useEffect(()=>{
navigator.mediaDevices.getUserMedia({video:true})
.then(stream=>{
let video = document.querySelector('video')
video.source = stream;
video.play();
})
.catch(e=>{
console.log(e)
})
})
return(
<video autoPlay ={true} id ="video"></video>
)
}
【问题讨论】:
标签: javascript reactjs webcam react-hooks