Hello,
Is there anyway to mute the local microphone?
Session.mute() doesnt seems to be working.
Best Regards,
Pjata
You need to get the local tracks off of the peerConnection and then mute the tracks. This is outside of the scope of SIP.js. See Session Description Handler documentation for information on how to get the peer connection.
I solved it like this:
session.getLocalStreams()[0].getAudioTracks()[0].stop()
session.getLocalStreams
is not forwards compatible with 0.8+. You need to get the peer connection and get the streams off of the peer connection.
so how can i do this?
You need to get the local tracks off of the peerConnection and then mute the tracks. This is outside of the scope of SIP.js. See Session Description Handler documentation for information on how to get the peer connection.
i did it this way
///mute
var pc = session.sessionDescriptionHandler.peerConnection;
pc.getLocalStreams().forEach(function (stream) {
stream.getAudioTracks().forEach(function (track) {
track.enabled = false;
});
});
i did it this way
///mute var pc = session.sessionDescriptionHandler.peerConnection; pc.getLocalStreams().forEach(function (stream) { stream.getAudioTracks().forEach(function (track) { track.enabled = false; }); });
For anyone finding this now:
Chrome says peerConnection.getLocalStreams()
shouldnt be used anymore. Instead use:
peerConnection.getSenders()
and peerConnection.getReceivers()
in 0.15.0 version is it turned out to be done like this
const pc: any = this.session.sessionDescriptionHandler.peerConnection
pc.getSenders().forEach((stream: any) => {
stream.track.enabled = false
})
thank you @koshelevvasya that worked for me!
sorry was late to the party. Question: how do i as the remote peer know the local peer has muted their microphone so that i can update the status from my end? Any event would fire when a track is enabled/disabled as mentioned by @koshelevvasya above?
@thanh-mel , the remote peer does not need to know that the microphone is muted. Maybe you need to use hold?
Any event would fire when a track is enabled/disabled
In my experience, yes. Because it is done using JavaScript
Most helpful comment
in 0.15.0 version is it turned out to be done like this