Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Failed to convert value to MediaStream

I am trying to implement Screen Capture API
https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture#capturing_screen_contents

I am building the same code in React JS,

when I place the following code I am getting an error "Failed to set the ‘srcObject’ property on ‘HTMLMediaElement’: Failed to convert value to ‘MediaStream’."

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<video id="video"></video>
video = document.getElementById("video");
video.srcObject = navigator.mediaDevices.getDisplayMedia(displayMediaOptions);```


Please someone help in resolving this issue

>Solution :

HTML

<video id="video"></video>

JS

video = document.getElementById("video");
 
async function startCapture() {
  

  try {
    video.srcObject = await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);
  } catch(err) {
    console.error("Error: " + err);
  }
  return captureStream;
}
startCapture()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading