|
@@ -136,26 +136,41 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
|
136
|
136
|
}
|
137
|
137
|
}
|
138
|
138
|
|
139
|
|
- var vid = document.createElement('video');
|
140
|
|
- // FIXME: the span should not be created here but on muc join
|
141
|
|
- var span = document.createElement('span');
|
|
139
|
+ var container;
|
|
140
|
+ var remotes = document.getElementById('remoteVideos');
|
142
|
141
|
if (data.peerjid) {
|
143
|
|
- // FIXME: how to name this span? data.peerjid is not set for jingle clients
|
144
|
|
- span.id = 'participant_' + Strophe.getResourceFromJid(data.peerjid);
|
145
|
|
- } else if (data.stream.id != 'mixedmslabel') {
|
146
|
|
- console.warn('can not associate stream', data.stream.id, 'with a participant');
|
|
142
|
+ container = document.getElementById('participant_' + Strophe.getResourceFromJid(data.peerjid));
|
|
143
|
+ if (!container) {
|
|
144
|
+ console.warn('no container for', data.peerjid);
|
|
145
|
+ // create for now...
|
|
146
|
+ // FIXME: should be removed
|
|
147
|
+ container = document.createElement('span');
|
|
148
|
+ container.id = 'participant_' + Strophe.getResourceFromJid(data.peerjid);
|
|
149
|
+ container.className = 'videocontainer';
|
|
150
|
+ remotes.appendChild(container);
|
|
151
|
+ } else {
|
|
152
|
+ //console.log('found container for', data.peerjid);
|
|
153
|
+ }
|
|
154
|
+ } else {
|
|
155
|
+ if (data.stream.id != 'mixedmslabel') {
|
|
156
|
+ console.warn('can not associate stream', data.stream.id, 'with a participant');
|
|
157
|
+ }
|
|
158
|
+ // FIXME: for the mixed ms we dont need a video -- currently
|
|
159
|
+ container = document.createElement('span');
|
|
160
|
+ container.className = 'videocontainer';
|
|
161
|
+ remotes.appendChild(container);
|
147
|
162
|
}
|
148
|
|
- span.className = 'videocontainer';
|
|
163
|
+ var vid = document.createElement('video');
|
149
|
164
|
var id = 'remoteVideo_' + sid + '_' + data.stream.id;
|
150
|
165
|
vid.id = id;
|
151
|
166
|
vid.autoplay = true;
|
152
|
167
|
vid.oncontextmenu = function () { return false; };
|
153
|
|
- var remotes = document.getElementById('remoteVideos');
|
154
|
|
- span.appendChild(vid);
|
|
168
|
+ container.appendChild(vid);
|
|
169
|
+ // TODO: make mixedstream display:none via css?
|
155
|
170
|
if (id.indexOf('mixedmslabel') != -1) {
|
156
|
|
- $(span).hide();
|
|
171
|
+ container.id = 'mixedstream';
|
|
172
|
+ $(container).hide();
|
157
|
173
|
}
|
158
|
|
- remotes.appendChild(span);
|
159
|
174
|
var sel = $('#' + id);
|
160
|
175
|
sel.hide();
|
161
|
176
|
RTC.attachMediaStream(sel, data.stream);
|
|
@@ -163,18 +178,16 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
|
163
|
178
|
data.stream.onended = function () {
|
164
|
179
|
console.log('stream ended', this.id);
|
165
|
180
|
var src = $('#' + id).attr('src');
|
166
|
|
- // FIXME: likewise, the parent should not be removed here
|
167
|
|
- // but on MUC part
|
168
|
|
- $('#' + id).parent().remove();
|
169
|
181
|
if (src === $('#largeVideo').attr('src')) {
|
170
|
182
|
// this is currently displayed as large
|
171
|
183
|
// pick the last visible video in the row
|
172
|
184
|
// if nobody else is left, this picks the local video
|
173
|
|
- var pick = $('#remoteVideos>span:visible:last>video').get(0);
|
|
185
|
+ var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>video').get(0);
|
174
|
186
|
// mute if localvideo
|
175
|
187
|
document.getElementById('largeVideo').volume = pick.volume;
|
176
|
188
|
document.getElementById('largeVideo').src = pick.src;
|
177
|
189
|
}
|
|
190
|
+ $('#' + id).parent().remove();
|
178
|
191
|
resizeThumbnails();
|
179
|
192
|
};
|
180
|
193
|
sel.click(
|
|
@@ -245,6 +258,11 @@ $(document).bind('joined.muc', function (event, jid, info) {
|
245
|
258
|
$(document).bind('entered.muc', function (event, jid, info, pres) {
|
246
|
259
|
console.log('entered', jid, info);
|
247
|
260
|
console.log(focus);
|
|
261
|
+ var container = document.createElement('span');
|
|
262
|
+ container.id = 'participant_' + Strophe.getResourceFromJid(jid);
|
|
263
|
+ container.className = 'videocontainer';
|
|
264
|
+ var remotes = document.getElementById('remoteVideos');
|
|
265
|
+ remotes.appendChild(container);
|
248
|
266
|
|
249
|
267
|
if (focus !== null) {
|
250
|
268
|
// FIXME: this should prepare the video
|
|
@@ -269,7 +287,11 @@ $(document).bind('entered.muc', function (event, jid, info, pres) {
|
269
|
287
|
$(document).bind('left.muc', function (event, jid) {
|
270
|
288
|
console.log('left', jid);
|
271
|
289
|
connection.jingle.terminateByJid(jid);
|
272
|
|
- // FIXME: this should actually hide the video already for a nicer UX
|
|
290
|
+ var container = document.getElementById('participant_' + Strophe.getResourceFromJid(jid));
|
|
291
|
+ if (container) {
|
|
292
|
+ // hide here, wait for video to close before removing
|
|
293
|
+ $(container).hide();
|
|
294
|
+ }
|
273
|
295
|
|
274
|
296
|
if (Object.keys(connection.emuc.members).length === 0) {
|
275
|
297
|
console.log('everyone left');
|