I am using getUserMedia to record using the user's browser:
stream.current = await navigator.mediaDevices.getUserMedia({
audio: {
echoCancellation: {exact: true}
},
video: {
width: { ideal: 240 }, height: { ideal: 160 }
}
});
window.stream = stream.current;
let options = {mimeType: 'video/webm;codecs=vp9,opus'};
try {
mediaRecorder.current = new MediaRecorder(window.stream, options);
} catch (e) {
console.error('Exception while creating MediaRecorder:', e);
return;
}
mediaRecorder.current.ondataavailable = (event:BlobEvent) => {
recordedBlobs.current.push(event.data);
uploadRecordedAnswer(recordedBlobs, mutationAddAttemptAnswer)
}
mediaRecorder.current.start();
However, the chrome recording icon does not go away even after I have stopped the recording, like this:
// All these does not get rid of the red icon
stream.current!.getTracks().forEach((track:MediaStreamTrack) => track.stop());
console.log(window.stream,window.stream.getTracks())
mediaRecorder.current!.stop()
window.stream.getTracks().forEach((track:MediaStreamTrack) => track.stop());
According to other posts the red icon should disappear after stream.getTracks().forEach((track:MediaStreamTrack) => track.stop()); but it still stays there for me. I know that the recording has already stopped because when I check the recorded video it stops after I click stop-recording, but the red icon still does not disappear
FYI I am using react useRef hence the stream.current