Просмотр исходного кода

Encapsulates direct access to .currentTime field into 'hasVideoStarted' method of RemoteVideo.

Removes duplicated logic for hiding video element when the user is muted.
j8
paweldomas 10 лет назад
Родитель
Сommit
103b5d71d0
2 измененных файлов: 18 добавлений и 18 удалений
  1. 12
    0
      modules/UI/videolayout/RemoteVideo.js
  2. 6
    18
      modules/UI/videolayout/VideoLayout.js

+ 12
- 0
modules/UI/videolayout/RemoteVideo.js Просмотреть файл

@@ -205,6 +205,18 @@ RemoteVideo.prototype.waitForPlayback = function (streamElement, stream) {
205 205
     streamElement.onplaying = onPlayingHandler;
206 206
 };
207 207
 
208
+/**
209
+ * Checks whether or not video stream exists and has started for this
210
+ * RemoteVideo instance. This is checked by trying to select video element in
211
+ * this container and checking if 'currentTime' field's value is greater than 0.
212
+ *
213
+ * @returns {*|boolean} true if this RemoteVideo has active video stream running
214
+ */
215
+RemoteVideo.prototype.hasVideoStarted = function () {
216
+    var videoSelector = this.selectVideoElement();
217
+    return videoSelector.length && videoSelector[0].currentTime > 0;
218
+};
219
+
208 220
 RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
209 221
     if (!this.container) {
210 222
         return;

+ 6
- 18
modules/UI/videolayout/VideoLayout.js Просмотреть файл

@@ -46,11 +46,10 @@ function onContactClicked (id) {
46 46
     }
47 47
 
48 48
     let remoteVideo = remoteVideos[id];
49
-    if (remoteVideo && remoteVideo.selectVideoElement().length) {
49
+    if (remoteVideo && remoteVideo.hasVideo()) {
50 50
         // It is not always the case that a videoThumb exists (if there is
51 51
         // no actual video).
52
-        if (remoteVideo.videoStream) {
53
-
52
+        if (remoteVideo.hasVideoStarted()) {
54 53
             // We have a video src, great! Let's update the large video
55 54
             // now.
56 55
             VideoLayout.handleVideoThumbClicked(false, id);
@@ -517,12 +516,6 @@ var VideoLayout = {
517 516
         } else {
518 517
             var remoteVideo = remoteVideos[id];
519 518
             remoteVideo.setMutedView(value);
520
-
521
-            var el = remoteVideo.selectVideoElement();
522
-            if (!value)
523
-                el.show();
524
-            else
525
-                el.hide();
526 519
         }
527 520
 
528 521
         if(this.isCurrentlyOnLarge(id))
@@ -575,17 +568,12 @@ var VideoLayout = {
575 568
         }
576 569
         currentDominantSpeaker = id;
577 570
 
578
-        // Obtain container for new dominant speaker.
579
-        let videoSel = remoteVideo.selectVideoElement();
580
-
581 571
         // Local video will not have container found, but that's ok
582 572
         // since we don't want to switch to local video.
583
-        if (!focusedVideoResourceJid && videoSel.length) {
584
-            // Update the large video if the video source is already available,
585
-            // otherwise wait for the "videoactive.jingle" event.
586
-            if (videoSel[0].currentTime > 0) {
587
-                this.updateLargeVideo(id);
588
-            }
573
+        // Update the large video if the video source is already available,
574
+        // otherwise wait for the "videoactive.jingle" event.
575
+        if (!focusedVideoResourceJid && remoteVideo.hasVideoStarted()) {
576
+            this.updateLargeVideo(id);
589 577
         }
590 578
     },
591 579
 

Загрузка…
Отмена
Сохранить