question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getUserMedia is undefined

See original GitHub issue

I have a problem with getUserMedia. The getUserMedia function doesn’t fire and when I tried to console.log(getUserMedia)it appears to be undefined

import { 
  RTCPeerConnection,
  RTCMediaStream,
  RTCIceCandidate,
  RTCSessionDescription,
  RTCView, MediaStreamTrack,
  mediaDevices,
  getUserMedia
} from 'react-native-webrtc';
function getLocalStream(isFront, callback) {
    let videoSourceId;

    // on android, you don't have to specify sourceId manually, just use facingMode
    // uncomment it if you want to specify
    if (Platform.OS === 'ios') {
        MediaStreamTrack.getSources(sourceInfos => {
            console.log("sourceInfos: ", sourceInfos);

            for (const i = 0; i < sourceInfos.length; i++) {
                const sourceInfo = sourceInfos[i];
                if (sourceInfo.kind == "video" && sourceInfo.facing == (isFront ? "front" : "back")) {
                    videoSourceId = sourceInfo.id;
                }
            }
        });
    }

    mediaDevices.enumerateDevices().then(sourceInfos => {
        console.log('.*****************.', getUserMedia);

        getUserMedia({
            audio: true,
            video: false
        }).then(stream => {
            console.log('getUserMedia success', stream);
            callback(stream);
            alert('We are OK');
        }).then(logError);
    });
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Aubynjcommented, Mar 29, 2019

@JinChengSu you were right It work and @saghul it return a promise, i achieve something like this with

mediaDevices.getUserMedia({audio: true, video: true})
        .then(stream =>{
            console.log("Stream is working now", stream)
            this.setState({selfViewSrc:stream.toURL})
        })
        .catch(e =>{console.log(e)})

I was able to get the stream promise. You can try this and let me know what you find

2reactions
saghulcommented, Feb 18, 2019

@mostafiz93 Please check the README. It’s now in mediaDevices.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigator.getUserMedia and Navigator.webkitGetUserMedia ...
getUserMedia , navigator.webkitGetUserMedia and navigator.mediaDevices can be used only in secure context (https), otherwise they are undefined.
Read more >
Cannot read property 'getUserMedia' of undefined · Issue #1200
I want to access the server using my IP address instead of localhost. I am getting the error "Uncaught TypeError: Cannot read property...
Read more >
MediaDevices.getUserMedia() - Web APIs | MDN
getUserMedia () is a powerful feature that can only be used in secure contexts; in insecure contexts, navigator.mediaDevices is undefined , preventing access...
Read more >
WebRTC Fix For getUserMedia Undefined On Local Hosts
WebRTC Fix For getUserMedia Undefined On Local Hosts ... Or it looks something like this: What this means is that is the browser...
Read more >
Help me: Error: Cannot read property 'getUserMedia' of ...
Help me: Error: Cannot read property 'getUserMedia' of undefined (Code and Console Log inside) · Install & Config · joeblyth2020 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found