|
@@ -163,10 +163,11 @@ RemoteVideo.prototype.removeRemoteStreamElement = function (stream, isVideo, id)
|
163
|
163
|
};
|
164
|
164
|
|
165
|
165
|
RemoteVideo.prototype.addRemoteStreamElement = function (sid, stream, thessrc) {
|
166
|
|
- var isVideo = stream.getVideoTracks().length > 0;
|
167
|
|
- if(!this.container)
|
|
166
|
+ if (!this.container)
|
168
|
167
|
return;
|
169
|
168
|
|
|
169
|
+ var self = this;
|
|
170
|
+ var isVideo = stream.getVideoTracks().length > 0;
|
170
|
171
|
var streamElement = SmallVideo.createStreamElement(sid, stream);
|
171
|
172
|
var newElementId = streamElement.id;
|
172
|
173
|
|
|
@@ -178,10 +179,20 @@ RemoteVideo.prototype.addRemoteStreamElement = function (sid, stream, thessrc) {
|
178
|
179
|
// If the container is currently visible we attach the stream.
|
179
|
180
|
if (!isVideo
|
180
|
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
|
198
|
var self = this;
|
|
@@ -232,26 +243,6 @@ RemoteVideo.prototype.addRemoteStreamElement = function (sid, stream, thessrc) {
|
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
|
247
|
* Show/hide peer container for the given resourceJid.
|
257
|
248
|
*/
|