Browse Source

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

master
paweldomas 10 years ago
parent
commit
4b8bc398dd

+ 14
- 0
modules/UI/util/UIUtil.js View File

78
         element.setAttribute("data-placement", position);
78
         element.setAttribute("data-placement", position);
79
         element.setAttribute("data-html", true);
79
         element.setAttribute("data-html", true);
80
         element.setAttribute("data-container", "body");
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 View File

201
     localVideo.oncontextmenu = function () { return false; };
201
     localVideo.oncontextmenu = function () { return false; };
202
 
202
 
203
     var localVideoContainer = document.getElementById('localVideoWrapper');
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
     var localVideoSelector = $('#' + localVideo.id);
207
     var localVideoSelector = $('#' + localVideo.id);
207
 
208
 

+ 3
- 1
modules/UI/videolayout/RemoteVideo.js View File

5
 var LargeVideo = require("./LargeVideo");
5
 var LargeVideo = require("./LargeVideo");
6
 var Avatar = require("../avatar/Avatar");
6
 var Avatar = require("../avatar/Avatar");
7
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
7
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
8
+var UIUtils = require("../util/UIUtil");
8
 
9
 
9
 function RemoteVideo(peerJid, VideoLayout) {
10
 function RemoteVideo(peerJid, VideoLayout) {
10
     this.peerJid = peerJid;
11
     this.peerJid = peerJid;
212
     var streamElement = SmallVideo.createStreamElement(sid, stream);
213
     var streamElement = SmallVideo.createStreamElement(sid, stream);
213
     var newElementId = streamElement.id;
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
     var sel = $('#' + newElementId);
219
     var sel = $('#' + newElementId);
218
     sel.hide();
220
     sel.hide();

Loading…
Cancel
Save