Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What causes the Failed to execute 'createObjectURL' error?

Tags:

angular

I am trying to take a snapshot with the laptop camera.

In used to work perfectly, but now I have an error in my console:

ERROR Error: Uncaught (in promise): TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided.

Here is my code (component.ts):

public ngAfterViewInit() {
    if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
        navigator.mediaDevices.getUserMedia({ video: true }).then(stream => {
            this.video.nativeElement.src = window.URL.createObjectURL(stream);
            this.video.nativeElement.play();
        });
    }
}
like image 690
Yamen Sta Avatar asked Jul 27 '26 20:07

Yamen Sta


1 Answers

The URL.createObjectURL() method has been removed from the MediaStream interface. This method has been deprecated in 2013 and superseded by assigning streams to HTMLMediaElement.srcObject. The old method was removed because it is less safe, requiring a call to URL.revokeOjbectURL() to end the stream. Other user agents have either deprecated (Firefox) or removed (Safari) this feature feature.

For more information, please refer here.

like image 65
Narendra Avatar answered Jul 29 '26 13:07

Narendra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!