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 () {
|
data.stream.onended = function () {
|
||||||
console.log('stream ended', this.id);
|
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.removed = true;
|
||||||
sel.remove();
|
sel.remove();
|
||||||
|
|
||||||
|
@ -455,9 +456,8 @@ function statsUpdated(statsCollector)
|
||||||
var peerStats = statsCollector.jid2stats[jid];
|
var peerStats = statsCollector.jid2stats[jid];
|
||||||
Object.keys(peerStats.ssrc2AudioLevel).forEach(function (ssrc)
|
Object.keys(peerStats.ssrc2AudioLevel).forEach(function (ssrc)
|
||||||
{
|
{
|
||||||
if (jid !== connection.emuc.myRoomJid)
|
AudioLevels.updateAudioLevel( Strophe.getResourceFromJid(jid),
|
||||||
AudioLevels.updateAudioLevel( Strophe.getResourceFromJid(jid),
|
peerStats.ssrc2AudioLevel[ssrc]);
|
||||||
peerStats.ssrc2AudioLevel[ssrc]);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -469,10 +469,9 @@ function statsUpdated(statsCollector)
|
||||||
*/
|
*/
|
||||||
function localStatsUpdated(statsCollector)
|
function localStatsUpdated(statsCollector)
|
||||||
{
|
{
|
||||||
if (connection.emuc.myRoomJid)
|
AudioLevels.updateAudioLevel(
|
||||||
AudioLevels.updateAudioLevel(
|
AudioLevels.LOCAL_LEVEL,
|
||||||
Strophe.getResourceFromJid(connection.emuc.myRoomJid),
|
statsCollector.audioLevel);
|
||||||
statsCollector.audioLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,6 +7,8 @@ var AudioLevels = (function(my) {
|
||||||
var SHADOW_COLOR = '#00ccff';
|
var SHADOW_COLOR = '#00ccff';
|
||||||
var audioLevelCanvasCache = {};
|
var audioLevelCanvasCache = {};
|
||||||
|
|
||||||
|
my.LOCAL_LEVEL = 'local';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the audio level canvas for the given peerJid. If the canvas
|
* Updates the audio level canvas for the given peerJid. If the canvas
|
||||||
* didn't exist we create it.
|
* didn't exist we create it.
|
||||||
|
@ -71,17 +73,12 @@ var AudioLevels = (function(my) {
|
||||||
my.updateAudioLevel = function (resourceJid, audioLevel) {
|
my.updateAudioLevel = function (resourceJid, audioLevel) {
|
||||||
drawAudioLevelCanvas(resourceJid, audioLevel);
|
drawAudioLevelCanvas(resourceJid, audioLevel);
|
||||||
|
|
||||||
var videoSpanId = null;
|
var videoSpanId = getVideoSpanId(resourceJid);
|
||||||
if (resourceJid
|
|
||||||
=== Strophe.getResourceFromJid(connection.emuc.myroomjid))
|
|
||||||
videoSpanId = 'localVideoContainer';
|
|
||||||
else
|
|
||||||
videoSpanId = 'participant_' + resourceJid;
|
|
||||||
|
|
||||||
var audioLevelCanvas = $('#' + videoSpanId + '>canvas').get(0);
|
var audioLevelCanvas = $('#' + videoSpanId + '>canvas').get(0);
|
||||||
|
|
||||||
if (!audioLevelCanvas)
|
if (!audioLevelCanvas)
|
||||||
return ;
|
return;
|
||||||
|
|
||||||
var drawContext = audioLevelCanvas.getContext('2d');
|
var drawContext = audioLevelCanvas.getContext('2d');
|
||||||
|
|
||||||
|
@ -92,6 +89,9 @@ var AudioLevels = (function(my) {
|
||||||
drawContext.drawImage(canvasCache, 0, 0);
|
drawContext.drawImage(canvasCache, 0, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resizes the given audio level canvas to match the given thumbnail size.
|
||||||
|
*/
|
||||||
function resizeAudioLevelCanvas(audioLevelCanvas,
|
function resizeAudioLevelCanvas(audioLevelCanvas,
|
||||||
thumbnailWidth,
|
thumbnailWidth,
|
||||||
thumbnailHeight) {
|
thumbnailHeight) {
|
||||||
|
@ -108,12 +108,8 @@ var AudioLevels = (function(my) {
|
||||||
*/
|
*/
|
||||||
function drawAudioLevelCanvas(resourceJid, audioLevel) {
|
function drawAudioLevelCanvas(resourceJid, audioLevel) {
|
||||||
if (!audioLevelCanvasCache[resourceJid]) {
|
if (!audioLevelCanvasCache[resourceJid]) {
|
||||||
var videoSpanId = null;
|
|
||||||
if (resourceJid
|
var videoSpanId = getVideoSpanId(resourceJid);
|
||||||
=== Strophe.getResourceFromJid(connection.emuc.myroomjid))
|
|
||||||
videoSpanId = 'localVideoContainer';
|
|
||||||
else
|
|
||||||
videoSpanId = 'participant_' + resourceJid;
|
|
||||||
|
|
||||||
var audioLevelCanvasOrig = $('#' + videoSpanId + '>canvas').get(0);
|
var audioLevelCanvasOrig = $('#' + videoSpanId + '>canvas').get(0);
|
||||||
|
|
||||||
|
@ -173,6 +169,22 @@ var AudioLevels = (function(my) {
|
||||||
return shadowLevel;
|
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.
|
* Indicates that the remote video has been resized.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue