How do I bind the output of a webcam to the srcObject
attribute of a video element?
I have the following video
element in my HTML
<video id="video" srcObject.bind="cameraStream" if.bind="cameraStream">Video stream not available.</video>
In my JavaScript file, I have the following
activate() {
navigator.mediaDevices.getUserMedia({video: true, audio: false})
.then((stream) => {
this.cameraStream = stream
console.log('this.cameraStream', this.cameraStream)
})
.catch((err) => {
console.error(`An error occurred:`, err)
})
}
The page asks for access to the webcam, and I’ve logged the value of this.cameraStream
and I get the stream object in the console, but I’m not getting any content in the video object.
Thank you in advance for your help.