瀏覽代碼

feat(ringoverlay): Change the background when the avatar is displayed

j8
hristoterezov 8 年之前
父節點
當前提交
dab5252746

+ 6
- 1
css/ringing/_ringing.scss 查看文件

@@ -9,6 +9,11 @@
9 9
     background: linear-gradient(transparent, #000);
10 10
     opacity: 0.8;
11 11
 
12
+    &.solidBG {
13
+        background: $defaultBackground;
14
+        opacity: 1;
15
+    }
16
+
12 17
     &__content {
13 18
         position: absolute;
14 19
         width: 400px;
@@ -33,4 +38,4 @@
33 38
             color: #333;
34 39
         }
35 40
     }
36
-}
41
+}

+ 36
- 7
modules/UI/ring_overlay/RingOverlay.js 查看文件

@@ -1,5 +1,21 @@
1
-/* global $ */
1
+/* global $, APP */
2 2
 /* jshint -W101 */
3
+import UIEvents from "../../../service/UI/UIEvents";
4
+
5
+/**
6
+ * Store the current ring overlay instance.
7
+ * Note: We want to have only 1 instance at a time.
8
+ */
9
+let overlay = null;
10
+
11
+/**
12
+ * Handler for UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED event.
13
+ * @param {boolean} shown indicates whether the avatar on the large video is
14
+ *  currently displayed or not.
15
+ */
16
+function onAvatarDisplayed(shown) {
17
+    overlay._changeBackground(shown);
18
+}
3 19
 
4 20
 /**
5 21
  * Shows ring overlay
@@ -19,6 +35,21 @@ class RingOverlay {
19 35
         this._setAudioTimeout();
20 36
     }
21 37
 
38
+    /**
39
+     * Chagnes the background of the ring overlay.
40
+     * @param {boolean} solid - if true the new background will be the solid
41
+     * one, otherwise the background will be default one.
42
+     * NOTE: The method just toggles solidBG css class.
43
+     */
44
+    _changeBackground(solid) {
45
+        const container = $("#" + this._containerId);
46
+        if(solid) {
47
+            container.addClass("solidBG");
48
+        } else {
49
+            container.removeClass("solidBG");
50
+        }
51
+    }
52
+
22 53
     /**
23 54
      * Builds and appends the ring overlay to the html document
24 55
      */
@@ -74,12 +105,6 @@ class RingOverlay {
74 105
     }
75 106
 }
76 107
 
77
-/**
78
- * Store the current ring overlay instance.
79
- * Note: We want to have only 1 instance at a time.
80
- */
81
-let overlay = null;
82
-
83 108
 export default {
84 109
     /**
85 110
      * Shows the ring overlay for the passed callee.
@@ -92,6 +117,8 @@ export default {
92 117
         }
93 118
 
94 119
         overlay = new RingOverlay(callee);
120
+        APP.UI.addListener(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED,
121
+            onAvatarDisplayed);
95 122
     },
96 123
 
97 124
     /**
@@ -104,6 +131,8 @@ export default {
104 131
         }
105 132
         overlay.destroy();
106 133
         overlay = null;
134
+        APP.UI.removeListener(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED,
135
+            onAvatarDisplayed);
107 136
         return true;
108 137
     },
109 138
 

+ 6
- 3
modules/UI/videolayout/LargeVideo.js 查看文件

@@ -164,11 +164,12 @@ class VideoContainer extends LargeContainer {
164 164
         return getStreamOwnerId(this.stream);
165 165
     }
166 166
 
167
-    constructor (onPlay) {
167
+    constructor (onPlay, emitter) {
168 168
         super();
169 169
         this.stream = null;
170 170
         this.videoType = null;
171 171
         this.localFlipX = true;
172
+        this.emitter = emitter;
172 173
 
173 174
         this.isVisible = false;
174 175
 
@@ -327,6 +328,8 @@ class VideoContainer extends LargeContainer {
327 328
             (show) ? interfaceConfig.DEFAULT_BACKGROUND : "#000");
328 329
 
329 330
         this.$avatar.css("visibility", show ? "visible" : "hidden");
331
+
332
+        this.emitter.emit(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED, show);
330 333
     }
331 334
 
332 335
     // We are doing fadeOut/fadeIn animations on parent div which wraps
@@ -385,12 +388,12 @@ class VideoContainer extends LargeContainer {
385 388
  * Manager for all Large containers.
386 389
  */
387 390
 export default class LargeVideoManager {
388
-    constructor () {
391
+    constructor (emitter) {
389 392
         this.containers = {};
390 393
 
391 394
         this.state = VIDEO_CONTAINER_TYPE;
392 395
         this.videoContainer = new VideoContainer(
393
-            () => this.resizeContainer(VIDEO_CONTAINER_TYPE));
396
+            () => this.resizeContainer(VIDEO_CONTAINER_TYPE), emitter);
394 397
         this.addContainer(VIDEO_CONTAINER_TYPE, this.videoContainer);
395 398
 
396 399
         // use the same video container to handle and desktop tracks

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

@@ -113,7 +113,7 @@ var VideoLayout = {
113 113
     },
114 114
 
115 115
     initLargeVideo () {
116
-        largeVideo = new LargeVideoManager();
116
+        largeVideo = new LargeVideoManager(eventEmitter);
117 117
         if(localFlipX) {
118 118
             largeVideo.onLocalFlipXChange(localFlipX);
119 119
         }

+ 6
- 1
service/UI/UIEvents.js 查看文件

@@ -105,5 +105,10 @@ export default {
105 105
      * event must contain the identifier of the container that has been toggled
106 106
      * and information about toggle on or off.
107 107
      */
108
-    SIDE_TOOLBAR_CONTAINER_TOGGLED: "UI.side_container_toggled"
108
+    SIDE_TOOLBAR_CONTAINER_TOGGLED: "UI.side_container_toggled",
109
+
110
+    /**
111
+     * Notifies that the avatar is displayed or not on the largeVideo.
112
+     */
113
+    LARGE_VIDEO_AVATAR_DISPLAYED: "UI.large_video_avatar_displayed"
109 114
 };

Loading…
取消
儲存