I have the following code for the web component which should start video streaming of the cam when the user clicks on the button
class WebStream extends LitElement {
constructor(){
super();
this.attachShadow({ mode: 'open' });
}
render() {
return html`
<button @click="${this.startStreaming}">start streaming</button>
`;
}
startStreaming() {
navigator.mediaDevices.getUserMedia({
video: true,
audio: true
}).then(function(mediaStream){
const shadowRoot = this;
let shadow = document.createElement("div")
shadowRoot.appendChild(shadow);
this.video = document.createElement('video');
shadow.appendChild(this.video);
this.video.srcObject = mediaStream
console.log(mediaStream)
this.video.setAttribute("width", "320");
this.video.setAttribute("height", "240");
this.video.play()
}.bind(this))
.catch(function(error){
console.log(error)
})
}
}
with this code it starts streaming, and I can listen the audio but on the browser I cant see anything