Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Fixes audio level interface in the single user in conference case.

yanas913cdb9c7a90
diff --git a/app.js b/app.js
index 9711e82090..c34a0605c7 100644
--- a/app.js
+++ b/app.js
@@ -293,7 +293,8 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
data.stream.onended = function () {
console.log('stream ended', this.id);
- // Mark video as removed to cancel waiting loop(if video is removed before has started)
+ // Mark video as removed to cancel waiting loop(if video is removed
+ // before has started)
sel.removed = true;
sel.remove();
@@ -455,9 +456,8 @@ function statsUpdated(statsCollector)
var peerStats = statsCollector.jid2stats[jid];
Object.keys(peerStats.ssrc2AudioLevel).forEach(function (ssrc)
{
- if (jid !== connection.emuc.myRoomJid)
- AudioLevels.updateAudioLevel( Strophe.getResourceFromJid(jid),
- peerStats.ssrc2AudioLevel[ssrc]);
+ AudioLevels.updateAudioLevel( Strophe.getResourceFromJid(jid),
+ peerStats.ssrc2AudioLevel[ssrc]);
});
});
}
@@ -469,10 +469,9 @@ function statsUpdated(statsCollector)
*/
function localStatsUpdated(statsCollector)
{
- if (connection.emuc.myRoomJid)
- AudioLevels.updateAudioLevel(
- Strophe.getResourceFromJid(connection.emuc.myRoomJid),
- statsCollector.audioLevel);
+ AudioLevels.updateAudioLevel(
+ AudioLevels.LOCAL_LEVEL,
+ statsCollector.audioLevel);
}
/**
diff --git a/audio_levels.js b/audio_levels.js
index a25da0116a..3a94fff22b 100644
--- a/audio_levels.js
+++ b/audio_levels.js
@@ -7,6 +7,8 @@ var AudioLevels = (function(my) {
var SHADOW_COLOR = '#00ccff';
var audioLevelCanvasCache = {};
+ my.LOCAL_LEVEL = 'local';
+
/**
* Updates the audio level canvas for the given peerJid. If the canvas
* didn't exist we create it.
@@ -71,17 +73,12 @@ var AudioLevels = (function(my) {
my.updateAudioLevel = function (resourceJid, audioLevel) {
drawAudioLevelCanvas(resourceJid, audioLevel);
- var videoSpanId = null;
- if (resourceJid
- === Strophe.getResourceFromJid(connection.emuc.myroomjid))
- videoSpanId = 'localVideoContainer';
- else
- videoSpanId = 'participant_' + resourceJid;
+ var videoSpanId = getVideoSpanId(resourceJid);
var audioLevelCanvas = $('#' + videoSpanId + '>canvas').get(0);
if (!audioLevelCanvas)
- return ;
+ return;
var drawContext = audioLevelCanvas.getContext('2d');
@@ -92,6 +89,9 @@ var AudioLevels = (function(my) {
drawContext.drawImage(canvasCache, 0, 0);
};
+ /**
+ * Resizes the given audio level canvas to match the given thumbnail size.
+ */
function resizeAudioLevelCanvas(audioLevelCanvas,
thumbnailWidth,
thumbnailHeight) {
@@ -108,12 +108,8 @@ var AudioLevels = (function(my) {
*/
function drawAudioLevelCanvas(resourceJid, audioLevel) {
if (!audioLevelCanvasCache[resourceJid]) {
- var videoSpanId = null;
- if (resourceJid
- === Strophe.getResourceFromJid(connection.emuc.myroomjid))
- videoSpanId = 'localVideoContainer';
- else
- videoSpanId = 'participant_' + resourceJid;
+
+ var videoSpanId = getVideoSpanId(resourceJid);
var audioLevelCanvasOrig = $('#' + videoSpanId + '>canvas').get(0);
@@ -173,6 +169,22 @@ var AudioLevels = (function(my) {
return shadowLevel;
};
+ /**
+ * Returns the video span id corresponding to the given resourceJid or local
+ * user.
+ */
+ function getVideoSpanId(resourceJid) {
+ var videoSpanId = null;
+ if (resourceJid === AudioLevels.LOCAL_LEVEL
+ || (connection.emuc.myroomjid && resourceJid
+ === Strophe.getResourceFromJid(connection.emuc.myroomjid)))
+ videoSpanId = 'localVideoContainer';
+ else
+ videoSpanId = 'participant_' + resourceJid;
+
+ return videoSpanId;
+ };
+
/**
* Indicates that the remote video has been resized.
*/