feross / simple-peer

📡 Simple WebRTC video, voice, and data channels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mute own microphone

pjebs opened this issue · comments

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.

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()