I am using an open source JavaScript library MediaStreamRecorder to record audio and video webRTC calls in Mozilla Firefox and Google Chrome.
The calls are recording successfully but I am facing the following issue.
If I use the time interval of 1 second (1000ms) in multiStreamRecorder.start()
then multiStreamRecorder.ondataavailable
event doesn't fire. And that's why No error or No log in console.
But, if I use the time interval of 1.5 seconds (1500ms) or greater, it fires the multiStreamRecorder.ondataavailable
event and everything works perfectly fine.
(Only in Video Case)
I want to keep the interval to 1 second (1000ms) only.
var ws;
function start() {
ws = new WebSocket("wss://xyz/");
ws.onopen = function () {
console.log("WebSocket has been opened!");
};
ws.onmessage = function (message) {
console.log("A messsage is received from WebSocket Server.", message);
};
ws.onclose = function (e) {
console.log('WebSocket is closed. Reconnection will be attempted in 5 second.', e.reason);
setTimeout(function () {
start();
}, 5000);
};
ws.onerror = function (err) {
console.error('WebSocket encountered an error: ', err.message, 'Closing WebSocket');
ws.close();
};
}
start();
function startRecording(localStream, remoteStream) {
if (localStream != null && remoteStream != null) {
multiStreamRecorder = new MultiStreamRecorder([localStream, remoteStream], "video/webm");
multiStreamRecorder.mimeType = "video/webm";
multiStreamRecorder.ondataavailable = function (blob) {
console.log("sending blob to websocket server", blob);
ws.send(blob);
};
// It doesn't work with the 1000ms time interval
multiStreamRecorder.start(1500);
}
else{
console.error("One or more streams are null.");
}
}
MediaRecorder.ondataavailable
not firing after windows is minimized or browser tab is switched... Is there any way to prevent it ? or if it is in the nature of the library then how can I resume the process once I switched the tabs and comeback to it again? – Yajairayajurveda