浏览代码

Fixes issue with black video when new stream element is inserted after the old one.

master
paweldomas 9 年前
父节点
当前提交
4b8bc398dd
共有 3 个文件被更改,包括 19 次插入2 次删除
  1. 14
    0
      modules/UI/util/UIUtil.js
  2. 2
    1
      modules/UI/videolayout/LocalVideo.js
  3. 3
    1
      modules/UI/videolayout/RemoteVideo.js

+ 14
- 0
modules/UI/util/UIUtil.js 查看文件

@@ -78,5 +78,19 @@ module.exports = {
78 78
         element.setAttribute("data-placement", position);
79 79
         element.setAttribute("data-html", true);
80 80
         element.setAttribute("data-container", "body");
81
+    },
82
+
83
+    /**
84
+     * Inserts given child element as the first one into the container.
85
+     * @param container the container to which new child element will be added
86
+     * @param newChild the new element that will be inserted into the container
87
+     */
88
+    prependChild: function (container, newChild) {
89
+        var firstChild = container.childNodes[0];
90
+        if (firstChild) {
91
+            container.insertBefore(newChild, firstChild);
92
+        } else {
93
+            container.appendChild(newChild);
94
+        }
81 95
     }
82 96
 };

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

@@ -201,7 +201,8 @@ LocalVideo.prototype.changeVideo = function (stream, isMuted) {
201 201
     localVideo.oncontextmenu = function () { return false; };
202 202
 
203 203
     var localVideoContainer = document.getElementById('localVideoWrapper');
204
-    localVideoContainer.appendChild(localVideo);
204
+    // Put the new video always in front
205
+    UIUtil.prependChild(localVideoContainer, localVideo);
205 206
 
206 207
     var localVideoSelector = $('#' + localVideo.id);
207 208
 

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

@@ -5,6 +5,7 @@ var AudioLevels = require("../audio_levels/AudioLevels");
5 5
 var LargeVideo = require("./LargeVideo");
6 6
 var Avatar = require("../avatar/Avatar");
7 7
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
8
+var UIUtils = require("../util/UIUtil");
8 9
 
9 10
 function RemoteVideo(peerJid, VideoLayout) {
10 11
     this.peerJid = peerJid;
@@ -212,7 +213,8 @@ RemoteVideo.prototype.addRemoteStreamElement = function (sid, stream, thessrc) {
212 213
     var streamElement = SmallVideo.createStreamElement(sid, stream);
213 214
     var newElementId = streamElement.id;
214 215
 
215
-    this.container.appendChild(streamElement);
216
+    // Put new stream element always in front
217
+    UIUtils.prependChild(this.container, streamElement);
216 218
 
217 219
     var sel = $('#' + newElementId);
218 220
     sel.hide();

正在加载...
取消
保存