I was trying to do some experiments with video steam online and I found some documents about online video streaming. However, I found an error in my console as mentioned below.
Uncaught TypeError: Failed to Execute ‘createObjectURL’ on ‘URL’: No Function Was Found That Matched the Signature Provided
My video streaming code was looking like the given below.
var video = document.querySelector('video'); video.src = window.URL.createObjectURL(stream);
I was stuck with the above error for a movement but finally I solved it.
The above error occurs in the browser because window.URL is no longer suitable for new browsers. In addition video.src is not valid to add live streaming to video element.
The solution is quite simple, just change your code according to my code as given below.
var video = document.querySelector('video'); video.srcObject = stream;
Here we removed the window.URL.createObjectURL method because it is no longer supported in new browsers. We also changed the src attribute of the video element to the srcObject attribute to handle the steam object. After that code was running without any errors.
I hope the above solution may work for your problem. Please do not write old and unsupported methods. In addition, always check the official documentation for the latest and updated methods to avoid unwanted errors.
Happy Debugging 😎