Make sure remote video exist before we use it

This commit is contained in:
yanas 2016-04-28 17:50:28 -05:00
parent 4a4e25de28
commit edf2f8114b
1 changed files with 30 additions and 12 deletions

View File

@ -207,7 +207,7 @@ var VideoLayout = {
if (APP.conference.isLocalId(id)) { if (APP.conference.isLocalId(id)) {
video = localVideoThumbnail; video = localVideoThumbnail;
} }
else if (remoteVideos[id]) { else {
video = remoteVideos[id]; video = remoteVideos[id];
} }
@ -423,7 +423,9 @@ var VideoLayout = {
* Shows the presence status message for the given video. * Shows the presence status message for the given video.
*/ */
setPresenceStatus (id, statusMsg) { setPresenceStatus (id, statusMsg) {
remoteVideos[id].setPresenceStatus(statusMsg); let remoteVideo = remoteVideos[id];
if (remoteVideo)
remoteVideo.setPresenceStatus(statusMsg);
}, },
/** /**
@ -496,9 +498,13 @@ var VideoLayout = {
if (APP.conference.isLocalId(id)) { if (APP.conference.isLocalId(id)) {
localVideoThumbnail.showAudioIndicator(isMuted); localVideoThumbnail.showAudioIndicator(isMuted);
} else { } else {
remoteVideos[id].showAudioIndicator(isMuted); let remoteVideo = remoteVideos[id];
if (!remoteVideo)
return;
remoteVideo.showAudioIndicator(isMuted);
if (APP.conference.isModerator) { if (APP.conference.isModerator) {
remoteVideos[id].updateRemoteVideoMenu(isMuted); remoteVideo.updateRemoteVideoMenu(isMuted);
} }
} }
}, },
@ -510,8 +516,9 @@ var VideoLayout = {
if (APP.conference.isLocalId(id)) { if (APP.conference.isLocalId(id)) {
localVideoThumbnail.setMutedView(value); localVideoThumbnail.setMutedView(value);
} else { } else {
var remoteVideo = remoteVideos[id]; let remoteVideo = remoteVideos[id];
remoteVideo.setMutedView(value); if (remoteVideo)
remoteVideo.setMutedView(value);
} }
if (this.isCurrentlyOnLarge(id)) { if (this.isCurrentlyOnLarge(id)) {
@ -528,7 +535,9 @@ var VideoLayout = {
APP.conference.isLocalId(id)) { APP.conference.isLocalId(id)) {
localVideoThumbnail.setDisplayName(displayName); localVideoThumbnail.setDisplayName(displayName);
} else { } else {
remoteVideos[id].setDisplayName(displayName, status); let remoteVideo = remoteVideos[id];
if (remoteVideo)
remoteVideo.setDisplayName(displayName, status);
} }
}, },
@ -650,9 +659,13 @@ var VideoLayout = {
console.error("No remote video for: " + resourceJid); console.error("No remote video for: " + resourceJid);
isReceived = false; isReceived = false;
} else if (resourceJid && } else if (resourceJid &&
//TOFIX: smallVideo may be undefined
smallVideo.isVisible() && smallVideo.isVisible() &&
lastNEndpoints.indexOf(resourceJid) < 0 && lastNEndpoints.indexOf(resourceJid) < 0 &&
localLastNSet.indexOf(resourceJid) >= 0) { localLastNSet.indexOf(resourceJid) >= 0) {
// TOFIX: if we're here we already know that the smallVideo
// exists. Look at the previous FIX above.
if (smallVideo) if (smallVideo)
smallVideo.showPeerContainer('avatar'); smallVideo.showPeerContainer('avatar');
else if (!APP.conference.isLocalId(resourceJid)) else if (!APP.conference.isLocalId(resourceJid))
@ -753,8 +766,9 @@ var VideoLayout = {
* @param object the stats data * @param object the stats data
*/ */
updateConnectionStats (id, percent, object) { updateConnectionStats (id, percent, object) {
if (remoteVideos[id]) { let remoteVideo = remoteVideos[id];
remoteVideos[id].updateStatsIndicator(percent, object); if (remoteVideo) {
remoteVideo.updateStatsIndicator(percent, object);
} }
}, },
@ -763,15 +777,19 @@ var VideoLayout = {
* @param id * @param id
*/ */
hideConnectionIndicator (id) { hideConnectionIndicator (id) {
remoteVideos[id].hideConnectionIndicator(); let remoteVideo = remoteVideos[id];
if (remoteVideo)
remoteVideo.hideConnectionIndicator();
}, },
/** /**
* Hides all the indicators * Hides all the indicators
*/ */
hideStats () { hideStats () {
for(var video in remoteVideos) { for (var video in remoteVideos) {
remoteVideos[video].hideIndicator(); let remoteVideo = remoteVideos[video];
if (remoteVideo)
remoteVideo.hideIndicator();
} }
localVideoThumbnail.hideIndicator(); localVideoThumbnail.hideIndicator();
}, },