WebAudioTrack icon indicating copy to clipboard operation
WebAudioTrack copied to clipboard

Turn off the microphone after recording

Open nikhiljadiya opened this issue 5 years ago • 1 comments

Can you help me how to turn off microphone after recording on browser?

nikhiljadiya avatar Jun 20 '20 05:06 nikhiljadiya

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);
	}
    
}

albashahmad avatar Sep 14 '20 11:09 albashahmad