feross/simple-peer

Mute own microphone

pjebs opened this issue · 1 comments

pjebs commented

There seems to be no way way to mute my own microphone.

I can mute other person's mic so that I can't hear them. But I can't stop other person from hearing me.

pjebs commented

The answer is:

if (window.SimplePeerInstance) {
		let streams = window.SimplePeerInstance.streams;
		if (streams.length === 0) {
			return;
		}

		let stream = streams[0];

		let tracks = stream.getAudioTracks();
		if (tracks.length === 0) {
			return;
		}

		for (let track of tracks) {
			track.enabled = !track.enabled;
		}
	}


, where window.SimplePeerInstance is the simple-peer object from new Peer()