Fixes audio level interface in the single user in conference case.
This commit is contained in:
parent
1dcbf7fce6
commit
913cdb9c7a
15
app.js
15
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue