Failed to execute ‘createObjectURL’ on ‘URL’

The previous work web page calls the camera to get the video and take pictures of the work, and the error is reported: failed to execute ‘createobjecturl’ on ‘URL’

The reason is that after chrome is upgraded, the new version of chrome no longer supports this usage. It’s the same with other mainstream browsers,

 
So the original code:

video.src = URL.createObjectURL(stream);

Need to be changed to

video.srcObject = stream;

A compatible writing is as follows:

try {
  this.srcObject = stream;} catch (error) {
  this.src = window.URL.createObjectURL(stream);}

 
 

Similar Posts: