How to Mute Microphone of the Media Stream in Webrtc?

I have tried the stream.getAudioTracks()[0].enabled = false, But it does not work, Moreover, The getAudioTracks() is not currently supported in firefox..

Moreover stream.getVideoTracks()[0].enabled = false only works in chrome, But not in firefox. I need a solution which is compatable with both.

you should set enabled attribute

stream.getAudioTracks()[0].enabled = false/true