0

I managed to create a video chat in my Cordova app using PhoneRTC. Now, I want to add a button that toggles mute on the local microphone output.

How can I do that?

Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288

2 Answers2

1

Use Session.renegotiate.

For example:

session.streams.audio = false;
session.renegotiate();
Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288
0

You don't want to renegotiate to implement muting.

You want to get the audio (and maybe video) mediastreamtrack, and do track.enabled = false. That makes it silence (audio) or black (video).

Renegotiation requires at least several RTT to complete and can fail (and Firefox doesn't support it yet, requiring creating a new PeerConnection to replace the old one).

jesup
  • 6,765
  • 27
  • 32
  • PhoneRTC (and the native Java/Objective C WebRTC API) doesn't support the `MediaTrack.enabled` property. – Alon Gubkin Oct 15 '14 at 23:09
  • That's unfortunate, as that's the only way to have it mute "now". Renegotiation is *not* an acceptable way to implement mute; it can be used (though I wouldn't generally recommend it) to reduce bandwidth use during mute, or to implement a delayed, maybe it will fail mute. – jesup Oct 21 '14 at 04:45