react-native-webrtc/react-native-webrtc-web-shim

RTCView with a mute method

Closed this issue ยท 3 comments

Hi @8BallBomBom ,

Is there a method to mute local stream for ONLY myself?

If I mute it as below, then the whole stream is muted and my audio is not sent to the other party.
If I don't mute myself, in my own video view I hear myself.

useEffect(() => {
	if (localStream && localStream.getAudioTracks().length > 0) {
		localStream.getAudioTracks()[0].enabled = false;
	}
}, [localStream]);

Hence I imagine if there can be a method for RTCView so that I can mute the voice only for myself.

...
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
	{
		Platform.OS === "web"
			? <RTCView key={`local-${callRenderValue}`} stream={localStream} style={{ flex: 1 }} />
			: <RTCView key={`local-${callRenderValue}`} streamURL={localStream ? localStream.toURL() : undefined} style={{ flex: 1 }} />
	}
</View>
<View style={{ flex: 1 }}>
	{
		Platform.OS === "web"
			? <RTCView key={`remote-${callRenderValue}`} stream={remoteStream ? (remoteStream.toURL ? remoteStream.toURL() : remoteStream) : undefined} style={{ flex: 1 }} />
			: <RTCView key={`remote-${callRenderValue}`} streamURL={remoteStream ? (remoteStream.toURL ? remoteStream.toURL() : remoteStream) : undefined} style={{ flex: 1 }} />
	}
</View>
<View style={{ flexDirection: "row", justifyContent: "space-around" }}>
	<Button title="End Call" onPress={endCall} />
</View>
...

You should be able to pass the muted boolean prop over to the local web RTCView ๐Ÿค”
Disabling the audio track itself would indeed create the result of muting that track on both sides, don't do that ๐Ÿ˜…

That worked, I am terribly sorry to bother you for such a primitive subject. ๐Ÿ˜ฌ

Closing...

PS: Happy new year. ๐ŸŒฒ๐Ÿฅณ

Ahahaha no worries, Happy Holidays and a Happy New Year ๐ŸŽ„ ๐Ÿฅณ


What i'll do is in a future update be more specific about the common props ๐Ÿ‘๐Ÿป