bigpotato
bigpotato

Reputation: 27507

React Native: How to mute volume?

How do you mute the volume in React Native (specifically for Android)?

I am using https://github.com/oney/react-native-webrtc but disabling the audio tracks for that doesn't seem to do anything, so I want to just mute the phone completely.

Upvotes: 4

Views: 4665

Answers (1)

Ali Reza
Ali Reza

Reputation: 125

I used offerToReceiveAudio : false options to tell my PeerConnection that don't capture the audio track , in createOffer method .

For remote PeerConnection muting use this :

const pc = new RTCPeerConnection();
pc.createOffer({offerToReceiveVideo: true , offerToReceiveAudio: false}).then(sdpOffer=>{
    /// 
});

And use these params for the local media stream :

const mediaParams = {
    video : true ,
    audio : false ,
    options:{ muted : true }
};
getUserMedia(mediaParams, (error, stream) => {});

But I guess there's no certain way to mute the RTCView directly .

Upvotes: 1

Related Questions