浏览代码

Removes 'wait for remote video' hack

master
paweldomas 9 年前
父节点
当前提交
9268da65c2
共有 1 个文件被更改,包括 16 次插入25 次删除
  1. 16
    25
      modules/UI/videolayout/RemoteVideo.js

+ 16
- 25
modules/UI/videolayout/RemoteVideo.js 查看文件

163
 };
163
 };
164
 
164
 
165
 RemoteVideo.prototype.addRemoteStreamElement = function (sid, stream, thessrc) {
165
 RemoteVideo.prototype.addRemoteStreamElement = function (sid, stream, thessrc) {
166
-    var isVideo = stream.getVideoTracks().length > 0;
167
-    if(!this.container)
166
+    if (!this.container)
168
         return;
167
         return;
169
 
168
 
169
+    var self = this;
170
+    var isVideo = stream.getVideoTracks().length > 0;
170
     var streamElement = SmallVideo.createStreamElement(sid, stream);
171
     var streamElement = SmallVideo.createStreamElement(sid, stream);
171
     var newElementId = streamElement.id;
172
     var newElementId = streamElement.id;
172
 
173
 
178
     // If the container is currently visible we attach the stream.
179
     // If the container is currently visible we attach the stream.
179
     if (!isVideo
180
     if (!isVideo
180
         || (this.container.offsetParent !== null && isVideo)) {
181
         || (this.container.offsetParent !== null && isVideo)) {
181
-        APP.RTC.attachMediaStream(sel, stream);
182
 
182
 
183
-        if (isVideo)
184
-            this.waitForRemoteVideo(sel, thessrc, stream);
183
+        // Register 'onplaying' listener to trigger 'videoactive' on VideoLayout
184
+        // when video playback starts
185
+        if (isVideo && stream.id !== 'mixedmslabel') {
186
+            var onPlayingHandler = function () {
187
+                // FIXME: why do i have to do this for FF?
188
+                APP.RTC.attachMediaStream(sel, stream);
189
+                self.VideoLayout.videoactive(sel, self.resourceJid);
190
+                sel.off("playing", onPlayingHandler);
191
+            };
192
+            sel.on("playing", onPlayingHandler);
193
+        }
194
+
195
+        APP.RTC.attachMediaStream(sel, stream);
185
     }
196
     }
186
 
197
 
187
     var self = this;
198
     var self = this;
232
     );
243
     );
233
 }
244
 }
234
 
245
 
235
-
236
-RemoteVideo.prototype.waitForRemoteVideo = function(selector, ssrc, stream) {
237
-    if (selector.removed || !selector.parent().is(":visible")) {
238
-        console.warn("Media removed before had started", selector);
239
-        return;
240
-    }
241
-
242
-    if (stream.id === 'mixedmslabel') return;
243
-
244
-    if (selector[0].currentTime > 0) {
245
-        APP.RTC.attachMediaStream(selector, stream); // FIXME: why do i have to do this for FF?
246
-        this.VideoLayout.videoactive(selector, this.resourceJid);
247
-    } else {
248
-        var self = this;
249
-        setTimeout(function () {
250
-            self.waitForRemoteVideo(selector, ssrc, stream);
251
-        }, 250);
252
-    }
253
-}
254
-
255
 /**
246
 /**
256
  * Show/hide peer container for the given resourceJid.
247
  * Show/hide peer container for the given resourceJid.
257
  */
248
  */

正在加载...
取消
保存