I am developing an iOS app with react-native. I wanted to use MediaRecorder which is still in 'experimental' phase. I turned it on in advanced Safari settings but when I try to use it in my app:
var mediaRecorder = new MediaRecorder(stream)
I get this error:
ReferenceError: Can't find variable: MediaRecorder
This feature works well in safari, but I can't get it to work in my app. Is there a way to turn it on in Xcode/real-native settings?
EDIT:
Here is the larger section of my code. I use react-native-webrtc that provides mediaDevices component. I do capture the stream, the problem I have is with MediaRecorder. I know that MediaRecorder works in safari browser, the question I have is if it can be used in a mobile iOS app and if so, how to enable it.
import {
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
RTCView,
MediaStream,
MediaStreamTrack,
mediaDevices,
registerGlobals
} from 'react-native-webrtc';
var mediaRecorder;
const pc_config = {
"iceServers": [
{
urls: 'stun:stun.l.google.com:19302'
}
]
}
var pc = new RTCPeerConnection(pc_config)
const success = (stream) => {
mediaRecorder = new MediaRecorder(stream) //this line throws the error
pc.addStream(stream)
}
const failure = (e) => {
console.log('getUserMedia Error: ', e)
}
const constraints = {
audio: true,
video: {
mandatory: {
minWidth: 200,
minHeight: 200*(16/9),
minFrameRate: 24
},
facingMode: "user"
}
}
mediaDevices.getUserMedia(constraints)
.then(success)
.catch(failure);