1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-09-01 21:21:58 +03:00

Add MatrixCall.setMicrophoneMuted

This commit is contained in:
Kegan Dougal
2015-10-19 16:21:13 +01:00
parent 0a28d6e950
commit d8c43d02ba

View File

@@ -259,6 +259,17 @@ MatrixCall.prototype.hangup = function(reason, suppressEvent) {
sendEvent(this, 'm.call.hangup', content);
};
/**
* Set whether the microphone should be muted or not.
* @param {boolean} muted True to mute the mic.
*/
MatrixCall.prototype.setMicrophoneMuted = function(muted) {
if (!this.localAVStream) {
return;
}
setAudioTracksEnabled(this.localAVStream, !muted);
};
/**
* Internal
* @private
@@ -288,10 +299,7 @@ MatrixCall.prototype._gotUserMediaForInvite = function(stream) {
}
this.localAVStream = stream;
var audioTracks = stream.getAudioTracks();
for (var i = 0; i < audioTracks.length; i++) {
audioTracks[i].enabled = true;
}
setAudioTracksEnabled(stream, true);
this.peerConn = _createPeerConnection(this);
this.peerConn.addStream(stream);
this.peerConn.createOffer(
@@ -326,10 +334,7 @@ MatrixCall.prototype._gotUserMediaForAnswer = function(stream) {
}
self.localAVStream = stream;
var audioTracks = stream.getAudioTracks();
for (var i = 0; i < audioTracks.length; i++) {
audioTracks[i].enabled = true;
}
setAudioTracksEnabled(stream, true);
self.peerConn.addStream(stream);
var constraints = {
@@ -631,6 +636,13 @@ MatrixCall.prototype._onAnsweredElsewhere = function(msg) {
terminate(this, "remote", "answered_elsewhere", true);
};
var setAudioTracksEnabled = function(stream, enabled) {
var audioTracks = stream.getAudioTracks();
for (var i = 0; i < audioTracks.length; i++) {
audioTracks[i].enabled = enabled;
}
};
var setState = function(self, state) {
var oldState = self.state;
self.state = state;