You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-09-03 08:42:03 +03:00
Add MatrixCall.setMicrophoneMuted
This commit is contained in:
@@ -259,6 +259,17 @@ MatrixCall.prototype.hangup = function(reason, suppressEvent) {
|
|||||||
sendEvent(this, 'm.call.hangup', content);
|
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
|
* Internal
|
||||||
* @private
|
* @private
|
||||||
@@ -288,10 +299,7 @@ MatrixCall.prototype._gotUserMediaForInvite = function(stream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.localAVStream = stream;
|
this.localAVStream = stream;
|
||||||
var audioTracks = stream.getAudioTracks();
|
setAudioTracksEnabled(stream, true);
|
||||||
for (var i = 0; i < audioTracks.length; i++) {
|
|
||||||
audioTracks[i].enabled = true;
|
|
||||||
}
|
|
||||||
this.peerConn = _createPeerConnection(this);
|
this.peerConn = _createPeerConnection(this);
|
||||||
this.peerConn.addStream(stream);
|
this.peerConn.addStream(stream);
|
||||||
this.peerConn.createOffer(
|
this.peerConn.createOffer(
|
||||||
@@ -326,10 +334,7 @@ MatrixCall.prototype._gotUserMediaForAnswer = function(stream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.localAVStream = stream;
|
self.localAVStream = stream;
|
||||||
var audioTracks = stream.getAudioTracks();
|
setAudioTracksEnabled(stream, true);
|
||||||
for (var i = 0; i < audioTracks.length; i++) {
|
|
||||||
audioTracks[i].enabled = true;
|
|
||||||
}
|
|
||||||
self.peerConn.addStream(stream);
|
self.peerConn.addStream(stream);
|
||||||
|
|
||||||
var constraints = {
|
var constraints = {
|
||||||
@@ -631,6 +636,13 @@ MatrixCall.prototype._onAnsweredElsewhere = function(msg) {
|
|||||||
terminate(this, "remote", "answered_elsewhere", true);
|
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 setState = function(self, state) {
|
||||||
var oldState = self.state;
|
var oldState = self.state;
|
||||||
self.state = state;
|
self.state = state;
|
||||||
|
Reference in New Issue
Block a user