I have using an application to record audio which uses the javaScript code but after recording its mic will never disable.
So please suggest me that how to mute/disable microphone using javaScript?
I have using an application to record audio which uses the javaScript code but after recording its mic will never disable.
So please suggest me that how to mute/disable microphone using javaScript?
You can stop stream created on MediaRecorder:
navigator.mediaDevices.getUserMedia({audio:true,video:false}).then(function(stream)
{
recorder = new MediaRecorder(stream);
});
recorder.stream.getAudioTracks().forEach(function(track){track.stop();});
recorder
outside of where you call new MediaRecorder
. Is that correct? –
Gibe The previous answer is not ideal because the tracks are actually ended and cannot recover after you called track.stop();
, so you cannot unmute for example. Better:
Mute
stream.getAudioTracks().forEach(function(track) {
track.enabled = false;
});
Unmute
stream.getAudioTracks().forEach(function(track) {
track.enabled = true;
});
© 2022 - 2024 — McMap. All rights reserved.