i have to a record audio for both desktop audio and micophone
currently i am using media recorder
const recFunction = async() => {
try {
const mediaDevices = await navigator.mediaDevices.getUserMedia(typeOfMedia)
if (mediaDevices.active === true) {
recStream = new MediaRecorder(mediaDevices, options);
recStream.ondataavailable = e => {
chunks.push(e.data);
if (recStream.state == 'inactive') {
let blob = new Blob(chunks, { type: 'audio/wav' });
$('#hiddenAudio').val(URL.createObjectURL(blob));
$('#sendButton').trigger("click");
document.getElementById("recordData").classList.remove("recordBoxHide")
// createAudioElement(URL.createObjectURL(blob))
}
}
recStream.onstop = () => {
chunks = []
}
recStream.start()
}
} catch (error) {
if (error) console.log(error);
}
}
but problem is that when I am recording desktop audio not recording while connecting earphones and if I disconnect earphones and recording again then desktop audio is recording successful >> that is my main problem please help me if any one has solution for this problem suggest to me some library or API if available in javascript
you can use recordrtc for audio and video recording
`