Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

navigator.mediaDevices is undefined

So I've made a WebRTC screen sharing app as a self-hosted alternative to Chrome Remote Desktop and other common remote desktop / game streaming services.

My dilemma isn't navigator.mediaDevices undefinded. Whenever I launch the app over a file:/// scheme it works perfectly; the same with https:// as mentioned within Mozilla's docs. But the problem is I don't want to host it as it has a few major security issue(s). So how would I host it on 192.168.XXX.XXXX without it giving the error? (I would like to host it on my local network so I can test it on other mobile devices.)

like image 238
MilkyDeveloper Avatar asked Mar 31 '20 18:03

MilkyDeveloper


People also ask

What is navigator MediaDevices?

The Navigator. mediaDevices read-only property returns a MediaDevices object, which provides access to connected media input devices like cameras and microphones, as well as screen sharing.

What is navigator getUserMedia?

The deprecated Navigator. getUserMedia() method prompts the user for permission to use up to one video input device (such as a camera or shared screen) and up to one audio input device (such as a microphone) as the source for a MediaStream .

What is getDisplayMedia?

getDisplayMedia() The MediaDevices interface's getDisplayMedia() method prompts the user to select and grant permission to capture the contents of a display or portion thereof (such as a window) as a MediaStream .


1 Answers

APIs with functions like getUserMedia, getDisplayMedia and enumerateDevices require a secure context, access to these from http: origins has been removed in Chrome back in 2019

For development, the easiest solution may be to create a self-signed certificate.

--UPDATE--

For development the easiest solution is to run from localhost, as that's considered secure - see https://blog.mozilla.org/webrtc/camera-microphone-require-https-in-firefox-68/ and https://w3c.github.io/webappsec-secure-contexts/#localhost

Comment from: Vlad Dinulescu

like image 85
Philipp Hancke Avatar answered Sep 22 '22 18:09

Philipp Hancke