Hello,
I’m new to React Native and so to React-Native-WebRTC.
Trying to create simple demo, I’m failling right at the beginning.
I get the following error when trying to invoke addStream:
TypeError: undefined is not a function
My simple source code, App.js:
import React, { useState } from ‘react’;
import type {Node} from ‘react’;
import {
Button,
View,
} from ‘react-native’;import {
ScreenCapturePickerView,
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
RTCView,
MediaStream,
MediaStreamTrack,
mediaDevices,
registerGlobals
} from ‘react-native-webrtc’;import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from ‘react-native/Libraries/NewAppScreen’;let cameraCount = 0;
let peerConstraints = {
iceServers: [
{
urls: ‘stun:stun.l.google.com:19302’
}
]
};let peerConnection = new RTCPeerConnection( peerConstraints );
const getMediaStream = async () => {
let mediaConstraints = {
audio: true,
video: {
frameRate: 30,
facingMode: ‘user’
}
};let localMediaStream;
let isVoiceOnly = false;try {
const mediaStream = await mediaDevices.getUserMedia( mediaConstraints );if ( isVoiceOnly ) { let videoTrack = await mediaStream.getVideoTracks()[ 0 ]; videoTrack.enabled = false; }; localMediaStream = mediaStream; console.log(mediaStream); peerConnection.addStream(localMediaStream);
} catch( err ) {
// Handle Error
console.log(err);
};
}const addMediaSteam = async () => {
}const releaseMediaStream = async () => {
}const App: () => Node = () => {
return (
);
};export default App;
Thank you for your help!