diff --git a/app.js b/app.js
index 66454e5a9..d4b47ae49 100644
--- a/app.js
+++ b/app.js
@@ -967,14 +967,21 @@ function toggleAudio() {
return;
}
- var localAudio = connection.jingle.localAudio;
- for (var idx = 0; idx < localAudio.getAudioTracks().length; idx++) {
- var audioEnabled = localAudio.getAudioTracks()[idx].enabled;
+ // It is not clear what is the right way to handle multiple tracks.
+ // So at least make sure that they are all muted or all unmuted and
+ // that we send presence just once.
+ var localAudioTracks = connection.jingle.localAudio.getAudioTracks();
+ if (localAudioTracks.length > 0) {
+ var audioEnabled = localAudioTracks[0].enabled;
+
+ for (var idx = 0; idx < localAudioTracks.length; idx++) {
+ localAudioTracks[idx].enabled = !audioEnabled;
+ }
- localAudio.getAudioTracks()[idx].enabled = !audioEnabled;
// isMuted is the opposite of audioEnabled
connection.emuc.addAudioInfoToPresence(audioEnabled);
connection.emuc.sendPresence();
+ VideoLayout.showLocalAudioIndicator(audioEnabled);
}
buttonClick("#mute", "icon-microphone icon-mic-disabled");
diff --git a/index.html b/index.html
index f12e30ad2..757b193d3 100644
--- a/index.html
+++ b/index.html
@@ -34,7 +34,7 @@
-
+
@@ -47,7 +47,7 @@
-
+
diff --git a/videolayout.js b/videolayout.js
index 156e41768..570591b48 100644
--- a/videolayout.js
+++ b/videolayout.js
@@ -766,6 +766,7 @@ var VideoLayout = (function (my) {
/**
* Shows audio muted indicator over small videos.
+ * @param {string} isMuted
*/
my.showAudioIndicator = function(videoSpanId, isMuted) {
var audioMutedSpan = $('#' + videoSpanId + '>span.audioMuted');
@@ -793,6 +794,14 @@ var VideoLayout = (function (my) {
}
};
+ /*
+ * Shows or hides the audio muted indicator over the local thumbnail video.
+ * @param {boolean} isMuted
+ */
+ my.showLocalAudioIndicator = function(isMuted) {
+ VideoLayout.showAudioIndicator('localVideoContainer', isMuted.toString());
+ };
+
/**
* Resizes the large video container.
*/
@@ -1166,19 +1175,19 @@ var VideoLayout = (function (my) {
* On audio muted event.
*/
$(document).bind('audiomuted.muc', function (event, jid, isMuted) {
- var videoSpanId = null;
if (jid === connection.emuc.myroomjid) {
- videoSpanId = 'localVideoContainer';
- } else {
- VideoLayout.ensurePeerContainerExists(jid);
- videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
+ // The local mute indicator is controlled locally
+ return;
}
+ VideoLayout.ensurePeerContainerExists(jid);
+
if (focus) {
mutedAudios[jid] = isMuted;
VideoLayout.updateRemoteVideoMenu(jid, isMuted);
}
+ var videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
if (videoSpanId)
VideoLayout.showAudioIndicator(videoSpanId, isMuted);
});