瀏覽代碼

Make sure remote video exist before we use it

j8
yanas 9 年之前
父節點
當前提交
edf2f8114b
共有 1 個檔案被更改,包括 30 行新增12 行删除
  1. 30
    12
      modules/UI/videolayout/VideoLayout.js

+ 30
- 12
modules/UI/videolayout/VideoLayout.js 查看文件

@@ -207,7 +207,7 @@ var VideoLayout = {
207 207
         if (APP.conference.isLocalId(id)) {
208 208
             video = localVideoThumbnail;
209 209
         }
210
-        else if (remoteVideos[id]) {
210
+        else {
211 211
             video = remoteVideos[id];
212 212
         }
213 213
 
@@ -423,7 +423,9 @@ var VideoLayout = {
423 423
      * Shows the presence status message for the given video.
424 424
      */
425 425
     setPresenceStatus (id, statusMsg) {
426
-        remoteVideos[id].setPresenceStatus(statusMsg);
426
+        let remoteVideo = remoteVideos[id];
427
+        if (remoteVideo)
428
+            remoteVideo.setPresenceStatus(statusMsg);
427 429
     },
428 430
 
429 431
     /**
@@ -496,9 +498,13 @@ var VideoLayout = {
496 498
         if (APP.conference.isLocalId(id)) {
497 499
             localVideoThumbnail.showAudioIndicator(isMuted);
498 500
         } else {
499
-            remoteVideos[id].showAudioIndicator(isMuted);
501
+            let remoteVideo = remoteVideos[id];
502
+            if (!remoteVideo)
503
+                return;
504
+
505
+            remoteVideo.showAudioIndicator(isMuted);
500 506
             if (APP.conference.isModerator) {
501
-                remoteVideos[id].updateRemoteVideoMenu(isMuted);
507
+                remoteVideo.updateRemoteVideoMenu(isMuted);
502 508
             }
503 509
         }
504 510
     },
@@ -510,8 +516,9 @@ var VideoLayout = {
510 516
         if (APP.conference.isLocalId(id)) {
511 517
             localVideoThumbnail.setMutedView(value);
512 518
         } else {
513
-            var remoteVideo = remoteVideos[id];
514
-            remoteVideo.setMutedView(value);
519
+            let remoteVideo = remoteVideos[id];
520
+            if (remoteVideo)
521
+                remoteVideo.setMutedView(value);
515 522
         }
516 523
 
517 524
         if (this.isCurrentlyOnLarge(id)) {
@@ -528,7 +535,9 @@ var VideoLayout = {
528 535
             APP.conference.isLocalId(id)) {
529 536
             localVideoThumbnail.setDisplayName(displayName);
530 537
         } else {
531
-            remoteVideos[id].setDisplayName(displayName, status);
538
+            let remoteVideo = remoteVideos[id];
539
+            if (remoteVideo)
540
+                remoteVideo.setDisplayName(displayName, status);
532 541
         }
533 542
     },
534 543
 
@@ -650,9 +659,13 @@ var VideoLayout = {
650 659
                     console.error("No remote video for: " + resourceJid);
651 660
                 isReceived = false;
652 661
             } else if (resourceJid &&
662
+                //TOFIX: smallVideo may be undefined
653 663
                 smallVideo.isVisible() &&
654 664
                 lastNEndpoints.indexOf(resourceJid) < 0 &&
655 665
                 localLastNSet.indexOf(resourceJid) >= 0) {
666
+
667
+                // TOFIX: if we're here we already know that the smallVideo
668
+                // exists. Look at the previous FIX above.
656 669
                 if (smallVideo)
657 670
                     smallVideo.showPeerContainer('avatar');
658 671
                 else if (!APP.conference.isLocalId(resourceJid))
@@ -753,8 +766,9 @@ var VideoLayout = {
753 766
      * @param object the stats data
754 767
      */
755 768
     updateConnectionStats (id, percent, object) {
756
-        if (remoteVideos[id]) {
757
-            remoteVideos[id].updateStatsIndicator(percent, object);
769
+        let remoteVideo = remoteVideos[id];
770
+        if (remoteVideo) {
771
+            remoteVideo.updateStatsIndicator(percent, object);
758 772
         }
759 773
     },
760 774
 
@@ -763,15 +777,19 @@ var VideoLayout = {
763 777
      * @param id
764 778
      */
765 779
     hideConnectionIndicator (id) {
766
-        remoteVideos[id].hideConnectionIndicator();
780
+        let remoteVideo = remoteVideos[id];
781
+        if (remoteVideo)
782
+            remoteVideo.hideConnectionIndicator();
767 783
     },
768 784
 
769 785
     /**
770 786
      * Hides all the indicators
771 787
      */
772 788
     hideStats () {
773
-        for(var video in remoteVideos) {
774
-            remoteVideos[video].hideIndicator();
789
+        for (var video in remoteVideos) {
790
+            let remoteVideo = remoteVideos[video];
791
+            if (remoteVideo)
792
+                remoteVideo.hideIndicator();
775 793
         }
776 794
         localVideoThumbnail.hideIndicator();
777 795
     },

Loading…
取消
儲存