I'm new in javascript, and I'm tring to make call via sip.
I wanna add mute button to my application, but I want it to mute my microphone. I mean, I don't want to mute my audio so I won't here the other side. I want the exact opposite-the other side to not hear me.
here is my html code:
<body onload="start()">
<audio id="remoteAudio"></audio>
<speaker></speaker>
<!-- mute -->
<button class="Rtable-cell numberBtn mute-btn" onclick="mute()">
<img src="//webrtc.phone.do/call/getMuteImg"/>
</button>
</body>
and here is my javascript code:
function createSimple(callerURI, displayName, remoteVideoElement) {
var configuration = {
aor,
media: {
remote: {
audio: remoteVideoElement,
},
},
ua: {
traceSip: true,
uri: aor,
displayName: displayName,
userAgentString: 'SIP-0.20.0.js',
},
};
return new SIP.Web.SimpleUser('wss://webrtc01.phone.do:443', configuration);
}
function start() {
remoteVideoElement = document.getElementById('remoteAudio');
remoteVideoElement.volume = 0.2;
simple = createSimple(aor, fromName, remoteVideoElement);
simple.connect();
}
I tried to do this:
function setStream(stream) {
myStream = stream;
}
var myStream;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia;
navigator.getUserMedia({ audio: true }, setStream, function () { alert('failed') });
function mute() {
myStream.getAudioTracks()[0].enabled = !(myStream.getAudioTracks()[0].enabled);
getAudioTracks().foreach(track=>{track.stop();})
}
and this:
function mute() {
remoteVideoElement.muted=true;
}
but it all mute only my audio. that, as I explained, is not what I want.
any ideas?