Search code examples
javascriptwebrtckurento

Mute/Unmute audio in Kurento with webRtcPeer connection


I am able to make video call between two individuals but now what I wanted to do is that I want to add a button to mute and unmute the audio while streaming video I search a lot on the internet but nothing works out for me.

then I found the configuration in options property of WebRtcPeerSendrecv which enables audio on connection but the problem is how I update or toggle it during the stream.

here is my code

 var videoInput = document.getElementById('videoInput');
 var videoOutput = document.getElementById('videoOutput');

 var constraints = {
   audio: true, //how do I toggle this during the stream.
   video: {
     width: 640,
     framerate: 15
   }
 };

var options = {
  localVideo: videoInput,
  remoteVideo: videoOutput,
  onicecandidate : onIceCandidate,
  mediaConstraints: constraints
};


var webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function(error) {
  if(error) return onError(error)

  this.generateOffer(onOffer)
});

I am also free for another alternative which helps me to integrate mute/unmute functionality in my stream.

I am stuck at this so bad for so long any kind of help is appreciable thanks in advance.


Solution

  • I found the solution there is a property in webRtcPeer after making peer connection which allows us to manipulate the video stream audioEnabled which is a boolean what I did is I just change its value to true/false as per my requirement like this

    webRtcPeer.audioEnabled = false //by default it will be false