File type change and undefined id
Hi there,
I have a an issue/question, not sure if its on my end im doing something wrong
I have a start func
const start = async () => {
if(activeRecordings.length){
await clearAllRecordings()
}
const recording = await createRecording();
if (recording && recording.id) {
const rec = await openCamera(recording.id);
if(rec){
setIsCameraOn(true)
}
setRecordingId(recording.id);
}
};
which is being by a useEffect when the user enters the page, that way the camera opens automatically. However when doing that the recording id is always "undefined-undefined"
The id is made up of the audio and device id's, which should be available if the browser has given permission to use them. If you have several devices it would select the default ones of either.
const recordingId = `${videoId}-${audioId}`;
So my guess is that this would be a permissions issue. Also please update to the latest version, which contains a fix to handle device re-detection after remount. Hope this helps? :)
Thank you for your response, im already on the latest version.
If I create a button that has an onClick with the start function then I will get the correct id
It might that the recording is starting before the audio and video devices are available
If I refresh the page and click start very fast I will have undefined Id, but if I wait 1-2 seconds and then click I will get the correct Id
Also, when starting the page, and NOT STARTING the recording I can see that the camera light and camera icons lights up for 1-2 seconds and turns off.
*im using a mac so im referring to the green light and green icons that shows up when the camera is being used.
@samuelweckstrom got it to work by placing devicesByType in the array dependency in the useEffect, also am I able to change the format to mp4? i know its possible on 'react-media-recorder'