|
|
@@ -41,24 +41,7 @@ JitsiLocalTrack.prototype.constructor = JitsiLocalTrack;
|
|
41
|
41
|
* @returns {Promise}
|
|
42
|
42
|
*/
|
|
43
|
43
|
JitsiLocalTrack.prototype.mute = function () {
|
|
44
|
|
- return new Promise(function (resolve, reject) {
|
|
45
|
|
-
|
|
46
|
|
- if(this.inMuteOrUnmuteProcess) {
|
|
47
|
|
- reject(new Error(JitsiTrackErrors.TRACK_MUTE_UNMUTE_IN_PROGRESS));
|
|
48
|
|
- return;
|
|
49
|
|
- }
|
|
50
|
|
- this.inMuteOrUnmuteProcess = true;
|
|
51
|
|
-
|
|
52
|
|
- this._setMute(true,
|
|
53
|
|
- function(){
|
|
54
|
|
- this.inMuteOrUnmuteProcess = false;
|
|
55
|
|
- resolve();
|
|
56
|
|
- }.bind(this),
|
|
57
|
|
- function(status){
|
|
58
|
|
- this.inMuteOrUnmuteProcess = false;
|
|
59
|
|
- reject(status);
|
|
60
|
|
- }.bind(this));
|
|
61
|
|
- }.bind(this));
|
|
|
44
|
+ return createMuteUnmutePromise(this, true);
|
|
62
|
45
|
}
|
|
63
|
46
|
|
|
64
|
47
|
/**
|
|
|
@@ -67,6 +50,16 @@ JitsiLocalTrack.prototype.mute = function () {
|
|
67
|
50
|
* @returns {Promise}
|
|
68
|
51
|
*/
|
|
69
|
52
|
JitsiLocalTrack.prototype.unmute = function () {
|
|
|
53
|
+ return createMuteUnmutePromise(this, false);
|
|
|
54
|
+}
|
|
|
55
|
+
|
|
|
56
|
+/**
|
|
|
57
|
+ * Creates Promise for mute/unmute operation.
|
|
|
58
|
+ * @param track the track that will be muted/unmuted
|
|
|
59
|
+ * @param mute whether to mute or unmute the track
|
|
|
60
|
+ */
|
|
|
61
|
+function createMuteUnmutePromise(track, mute)
|
|
|
62
|
+{
|
|
70
|
63
|
return new Promise(function (resolve, reject) {
|
|
71
|
64
|
|
|
72
|
65
|
if(this.inMuteOrUnmuteProcess) {
|
|
|
@@ -75,7 +68,7 @@ JitsiLocalTrack.prototype.unmute = function () {
|
|
75
|
68
|
}
|
|
76
|
69
|
this.inMuteOrUnmuteProcess = true;
|
|
77
|
70
|
|
|
78
|
|
- this._setMute(false,
|
|
|
71
|
+ this._setMute(mute,
|
|
79
|
72
|
function(){
|
|
80
|
73
|
this.inMuteOrUnmuteProcess = false;
|
|
81
|
74
|
resolve();
|
|
|
@@ -84,7 +77,7 @@ JitsiLocalTrack.prototype.unmute = function () {
|
|
84
|
77
|
this.inMuteOrUnmuteProcess = false;
|
|
85
|
78
|
reject(status);
|
|
86
|
79
|
}.bind(this));
|
|
87
|
|
- }.bind(this));
|
|
|
80
|
+ }.bind(track));
|
|
88
|
81
|
}
|
|
89
|
82
|
|
|
90
|
83
|
/**
|