|
@@ -74,6 +74,25 @@ $(ContactList).bind('contactclicked', function(event, id) {
|
74
|
74
|
}
|
75
|
75
|
});
|
76
|
76
|
|
|
77
|
+/**
|
|
78
|
+ * Returns the corresponding resource id to the given peer container
|
|
79
|
+ * DOM element.
|
|
80
|
+ *
|
|
81
|
+ * @return the corresponding resource id to the given peer container
|
|
82
|
+ * DOM element
|
|
83
|
+ */
|
|
84
|
+function getPeerContainerResourceId (containerElement) {
|
|
85
|
+ if (localVideoThumbnail.container === containerElement) {
|
|
86
|
+ return localVideoThumbnail.id;
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+ let i = containerElement.id.indexOf('participant_');
|
|
90
|
+
|
|
91
|
+ if (i >= 0) {
|
|
92
|
+ return containerElement.id.substring(i + 12);
|
|
93
|
+ }
|
|
94
|
+}
|
|
95
|
+
|
77
|
96
|
|
78
|
97
|
var VideoLayout = {
|
79
|
98
|
init (emitter) {
|
|
@@ -168,58 +187,57 @@ var VideoLayout = {
|
168
|
187
|
* another one instead.
|
169
|
188
|
*/
|
170
|
189
|
updateRemovedVideo (id) {
|
|
190
|
+ if (id !== LargeVideo.getId()) {
|
|
191
|
+ return;
|
|
192
|
+ }
|
|
193
|
+
|
171
|
194
|
let newId;
|
172
|
195
|
|
173
|
|
- if (id === LargeVideo.getId()) {
|
174
|
|
- // We'll show user's avatar if he is the dominant speaker or if
|
175
|
|
- // his video thumbnail is pinned
|
176
|
|
- if (remoteVideos[id] &&
|
177
|
|
- id === focusedVideoResourceJid ||
|
178
|
|
- id === currentDominantSpeaker) {
|
179
|
|
- newId = id;
|
180
|
|
- } else {
|
181
|
|
- // Otherwise select last visible video
|
182
|
|
- newId = this.electLastVisibleVideo();
|
183
|
|
- }
|
184
|
|
- LargeVideo.updateLargeVideo(id);
|
|
196
|
+ // We'll show user's avatar if he is the dominant speaker or if
|
|
197
|
+ // his video thumbnail is pinned
|
|
198
|
+ if (remoteVideos[id] && (id === focusedVideoResourceJid || id === currentDominantSpeaker)) {
|
|
199
|
+ newId = id;
|
|
200
|
+ } else {
|
|
201
|
+ // Otherwise select last visible video
|
|
202
|
+ newId = this.electLastVisibleVideo();
|
185
|
203
|
}
|
|
204
|
+
|
|
205
|
+ LargeVideo.updateLargeVideo(newId);
|
186
|
206
|
},
|
187
|
207
|
|
188
|
208
|
electLastVisibleVideo () {
|
189
|
209
|
// pick the last visible video in the row
|
190
|
210
|
// if nobody else is left, this picks the local video
|
191
|
|
- var jid;
|
192
|
|
- var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last');
|
|
211
|
+ let pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last');
|
193
|
212
|
if (pick.length) {
|
194
|
|
- jid = VideoLayout.getPeerContainerResourceJid(pick[0]);
|
195
|
|
- if (!remoteVideos[jid]) {
|
196
|
|
- // The RemoteVideo was removed (but the DOM elements may still
|
197
|
|
- // exist).
|
198
|
|
- jid = null;
|
|
213
|
+ let id = getPeerContainerResourceId(pick[0]);
|
|
214
|
+ if (remoteVideos[id]) {
|
|
215
|
+ console.info("electLastVisibleVideo: " + id);
|
|
216
|
+ return id;
|
199
|
217
|
}
|
|
218
|
+ // The RemoteVideo was removed (but the DOM elements may still
|
|
219
|
+ // exist).
|
200
|
220
|
}
|
201
|
221
|
|
202
|
|
- if (!jid) {
|
203
|
|
- console.info("Last visible video no longer exists");
|
204
|
|
- pick = $('#remoteVideos>span[id!="mixedstream"]');
|
205
|
|
- if (pick.length) {
|
206
|
|
- jid = VideoLayout.getPeerContainerResourceJid(pick[0]);
|
207
|
|
- if (!remoteVideos[jid]) {
|
208
|
|
- // The RemoteVideo was removed (but the DOM elements may
|
209
|
|
- // still exist).
|
210
|
|
- jid = null;
|
211
|
|
- }
|
|
222
|
+ console.info("Last visible video no longer exists");
|
|
223
|
+ pick = $('#remoteVideos>span[id!="mixedstream"]');
|
|
224
|
+ if (pick.length) {
|
|
225
|
+ let id = getPeerContainerResourceId(pick[0]);
|
|
226
|
+ if (remoteVideos[id]) {
|
|
227
|
+ console.info("electLastVisibleVideo: " + id);
|
|
228
|
+ return id;
|
212
|
229
|
}
|
|
230
|
+ // The RemoteVideo was removed (but the DOM elements may
|
|
231
|
+ // still exist).
|
213
|
232
|
}
|
214
|
233
|
|
215
|
|
- if (!jid) {
|
216
|
|
- // Go with local video
|
217
|
|
- console.info("Fallback to local video...");
|
218
|
|
- jid = APP.xmpp.myResource();
|
219
|
|
- }
|
|
234
|
+ // Go with local video
|
|
235
|
+ console.info("Fallback to local video...");
|
220
|
236
|
|
221
|
|
- console.info("electLastVisibleVideo: " + jid);
|
222
|
|
- return jid;
|
|
237
|
+ let id = APP.conference.localId;
|
|
238
|
+ console.info("electLastVisibleVideo: " + id);
|
|
239
|
+
|
|
240
|
+ return id;
|
223
|
241
|
},
|
224
|
242
|
|
225
|
243
|
onRemoteStreamAdded (stream) {
|
|
@@ -508,24 +526,6 @@ var VideoLayout = {
|
508
|
526
|
return [availableWidth, availableHeight];
|
509
|
527
|
},
|
510
|
528
|
|
511
|
|
- /**
|
512
|
|
- * Returns the corresponding resource jid to the given peer container
|
513
|
|
- * DOM element.
|
514
|
|
- *
|
515
|
|
- * @return the corresponding resource jid to the given peer container
|
516
|
|
- * DOM element
|
517
|
|
- */
|
518
|
|
- getPeerContainerResourceJid (containerElement) {
|
519
|
|
- if (localVideoThumbnail.container === containerElement) {
|
520
|
|
- return localVideoThumbnail.getId();
|
521
|
|
- }
|
522
|
|
-
|
523
|
|
- var i = containerElement.id.indexOf('participant_');
|
524
|
|
-
|
525
|
|
- if (i >= 0)
|
526
|
|
- return containerElement.id.substring(i + 12);
|
527
|
|
- },
|
528
|
|
-
|
529
|
529
|
/**
|
530
|
530
|
* On audio muted event.
|
531
|
531
|
*/
|
|
@@ -671,7 +671,7 @@ var VideoLayout = {
|
671
|
671
|
|
672
|
672
|
// Handle LastN/local LastN changes.
|
673
|
673
|
$('#remoteVideos>span').each(function( index, element ) {
|
674
|
|
- var resourceJid = VideoLayout.getPeerContainerResourceJid(element);
|
|
674
|
+ var resourceJid = getPeerContainerResourceId(element);
|
675
|
675
|
|
676
|
676
|
// We do not want to process any logic for our own(local) video
|
677
|
677
|
// because the local participant is never in the lastN set.
|