WebAudioTrack
WebAudioTrack copied to clipboard
Turn off the microphone after recording
Can you help me how to turn off microphone after recording on browser?
Call the followng (assuming your object called audioTrack) :
function stopMic() {
try {
//when you call recording this will work
audioTrack.microphoneStream.getAudioTracks()[0].stop();
audioTrack.microphoneStream = null;
}
catch(error) {
try {
//when you did not call recoding this will work
audioTrack.startRecording(function() {
audioTrack.stopRecording(function() {
audioTrack.microphoneStream.getAudioTracks()[0].stop();
audioTrack.microphoneStream = null;
});
});
}
catch(error1) {
console.log(error1);
}
console.log(error);
}
}