Skip to content Skip to sidebar Skip to footer

Firefox: Navigator.getusermedia Is Not A Function

I'm playing with browser and audio. I'm doing this var session = { audio: true, video: false }; var recordRTC = null; navigator.

Solution 1:

It's not supported unprefixed yet. See http://caniuse.com/#search=getusermedia

You'll need to get the browser-specific prefix and use that. As posted in another answer:

navigator.getUserMedia = ( navigator.getUserMedia ||
                       navigator.webkitGetUserMedia ||
                       navigator.mozGetUserMedia ||
                       navigator.msGetUserMedia);

This will set navigator.getUserMedia to whatever it detects to be the proper prefixed version.

Solution 2:

Since navigator.getUserMedia() is deprecated, use this :

navigator.getUserMedia = (
    navigator.getUserMedia ||
    navigator.webkitGetUserMedia ||
    navigator.mozGetUserMedia ||
    navigator.msGetUserMedia
);

if (typeof navigator.mediaDevices.getUserMedia === 'undefined') {
    navigator.getUserMedia({
        audio: true
    }, streamHandler, errorHandler);
} else {
    navigator.mediaDevices.getUserMedia({
        audio: true
    }).then(streamHandler).catch(errorHandler);
}

Solution 3:

Check the MDN page, especially the first part of the first example:

navigator.getUserMedia = ( navigator.getUserMedia ||
                       navigator.webkitGetUserMedia ||
                       navigator.mozGetUserMedia ||
                       navigator.msGetUserMedia);

It's not that well-supported - you'll need browser prefixes.

Solution 4:

Navigator.getUserMedia() is deprecated, advised to use MediaDevices.getUserMedia()

asyncfunctiongetMedia(pc) {
  let stream = null;

  try {
    stream = await navigator.mediaDevices.getUserMedia(constraints);
    /* use the stream */
  } catch(err) {
    /* handle the error */
  }
}

Solution 5:

The Problem is

If the current document isn't loaded securely, navigator.mediaDevices will be undefined, and you cannot use getUserMedia(). See Security for more information on this and other security issues related to using getUserMedia() as given in https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

after searching, I got the solution try Following steps:

  1. Open Chrome browser, Type chrome://flags/#unsafely-treat-insecure-origin-as-secure in the url.

  2. Add the path of your host/ local url (ex. localhost/myproject or YOUR_HOSTNAME)

  3. Select as Enabled.

  4. Relaunch Browser.

Post a Comment for "Firefox: Navigator.getusermedia Is Not A Function"