@reactoo/watchtogether-sdk-js 2.6.85 → 2.6.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/watchtogether-sdk.js +3 -3
- package/dist/watchtogether-sdk.min.js +2 -2
- package/example/bulk_join_room/bulk_join_room_2.html +79 -31
- package/example/bulk_join_room/persons_gifs_talent/harry-kane.mp4 +0 -0
- package/package.json +1 -1
- package/src/models/asset.js +2 -2
- package/src/models/room.js +2 -2
|
@@ -64,6 +64,12 @@
|
|
|
64
64
|
<input type="checkbox" id="fetch-names" onchange="applySettingsFromForm()">
|
|
65
65
|
</div>
|
|
66
66
|
|
|
67
|
+
<div class="form-group --advanced">
|
|
68
|
+
<label for="talents-select">Talents</label>
|
|
69
|
+
<select id="talents-select"></select>
|
|
70
|
+
<button type="button" onclick="addTalent()">Add</button>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
67
73
|
<div class="form-group">
|
|
68
74
|
<button type="button" class="--advanced" onclick="resetSettings()">Reset settings</button>
|
|
69
75
|
<button type="button" class="--high-quality" onclick="toggleAdvancedSettings()">Toggle advanced settings</button>
|
|
@@ -144,10 +150,15 @@
|
|
|
144
150
|
instanceType: "reactooDemo",
|
|
145
151
|
swaggerUrl: "https://api.reactoo.com/v3/swagger.json",
|
|
146
152
|
fetchNames: false,
|
|
153
|
+
talentsSelect: [],
|
|
147
154
|
participantsNames: [],
|
|
148
155
|
emojiSparkingInterval: 180,
|
|
149
156
|
};
|
|
150
157
|
|
|
158
|
+
const talents = {
|
|
159
|
+
'harry-kane': {displayname: 'Harry Kane', bio: 'Professional footballer'},
|
|
160
|
+
};
|
|
161
|
+
|
|
151
162
|
const gifsCount_lq = 32; // Number of gifs in ./persons_gifs_lq folder
|
|
152
163
|
const gifsCount_hq = 17; // Number of gifs in ./persons_gifs_hq folder
|
|
153
164
|
let gifsCount = gifsCount_hq + gifsCount_lq;
|
|
@@ -169,6 +180,7 @@
|
|
|
169
180
|
instanceType: document.getElementById("instance-type"),
|
|
170
181
|
swaggerUrl: document.getElementById("swagger-url"),
|
|
171
182
|
fetchNames: document.getElementById("fetch-names"),
|
|
183
|
+
talentsSelect: document.getElementById("talents-select"),
|
|
172
184
|
participantsNames: document.getElementById("participants-names"),
|
|
173
185
|
emojiSparkingInterval: document.getElementById("emoji-sparking-interval"),
|
|
174
186
|
},
|
|
@@ -222,7 +234,9 @@
|
|
|
222
234
|
if (deleteInstead) {
|
|
223
235
|
url.searchParams.delete(settingsUrlParameterName);
|
|
224
236
|
} else {
|
|
225
|
-
|
|
237
|
+
const copyOfSettings = JSON.parse(JSON.stringify(settings));
|
|
238
|
+
delete copyOfSettings.talentsSelect;
|
|
239
|
+
url.searchParams.set(settingsUrlParameterName, JSON.stringify(copyOfSettings));
|
|
226
240
|
}
|
|
227
241
|
history.replaceState (null, '', url);
|
|
228
242
|
}
|
|
@@ -277,6 +291,8 @@
|
|
|
277
291
|
elements.form.fetchNames.checked = settings.fetchNames;
|
|
278
292
|
elements.form.participantsNames.value = settings.participantsNames.join("\n");
|
|
279
293
|
elements.form.emojiSparkingInterval.value = settings.emojiSparkingInterval;
|
|
294
|
+
|
|
295
|
+
updateTalentsSelectList();
|
|
280
296
|
}
|
|
281
297
|
|
|
282
298
|
// ====================== Main Logic ==================================
|
|
@@ -292,7 +308,6 @@
|
|
|
292
308
|
if (usedGifsIds.length >= gifsCount) {
|
|
293
309
|
usedGifsIds = [];
|
|
294
310
|
usedGifsTimes++;
|
|
295
|
-
|
|
296
311
|
}
|
|
297
312
|
|
|
298
313
|
const availableGifsIds = new Array(gifsCount).fill().map((_, index) => index+1).filter(e => !usedGifsIds.includes(e));
|
|
@@ -305,8 +320,6 @@
|
|
|
305
320
|
randomNotUsedGifId = Math.min(...availableGifsIds);
|
|
306
321
|
}
|
|
307
322
|
|
|
308
|
-
// console.log(randomNotUsedGifId);
|
|
309
|
-
|
|
310
323
|
if (randomNotUsedGifId) {
|
|
311
324
|
usedGifsIds.push(randomNotUsedGifId);
|
|
312
325
|
return randomNotUsedGifId;
|
|
@@ -315,7 +328,7 @@
|
|
|
315
328
|
}
|
|
316
329
|
}
|
|
317
330
|
|
|
318
|
-
function createParticipant(participantOrder) {
|
|
331
|
+
function createParticipant(participantOrder, talentKey) {
|
|
319
332
|
|
|
320
333
|
// const gifId = getRandomNotUsedGifId();
|
|
321
334
|
const gifId = getRandomNotUsedGifId() + usedGifsTimes * gifsCount;
|
|
@@ -326,11 +339,11 @@
|
|
|
326
339
|
|
|
327
340
|
let gifUrl;
|
|
328
341
|
|
|
329
|
-
if (
|
|
330
|
-
|
|
342
|
+
if (talentKey) {
|
|
343
|
+
gifUrl = `./persons_gifs_talent/${talentKey}.mp4`;
|
|
344
|
+
} else if (settings.participantsHighQuality) {
|
|
331
345
|
gifUrl = `./persons_gifs_hq/${gifId - usedGifsTimes * gifsCount}.mp4`;
|
|
332
346
|
} else {
|
|
333
|
-
// console.log("lq");
|
|
334
347
|
gifUrl = `./persons_gifs_lq/${gifId - usedGifsTimes * gifsCount}.gif`;
|
|
335
348
|
}
|
|
336
349
|
|
|
@@ -345,7 +358,7 @@
|
|
|
345
358
|
let canvasElement;
|
|
346
359
|
let canvasContext;
|
|
347
360
|
|
|
348
|
-
if (settings.participantsHighQuality){
|
|
361
|
+
if (talentKey || settings.participantsHighQuality){
|
|
349
362
|
canvasElement = document.createElement('video')
|
|
350
363
|
canvasElement.setAttribute('title', `Video ID - ` + gifId);
|
|
351
364
|
canvasElement.src = gifUrl;
|
|
@@ -355,7 +368,6 @@
|
|
|
355
368
|
canvasElement.autoplay = true;
|
|
356
369
|
canvasElement.loop = true;
|
|
357
370
|
containerElement.appendChild(canvasElement);
|
|
358
|
-
// console.log(canvasElement);
|
|
359
371
|
} else {
|
|
360
372
|
canvasElement = document.createElement('canvas');
|
|
361
373
|
canvasElement.setAttribute('title', `Gif ID - ` + gifId);
|
|
@@ -363,11 +375,6 @@
|
|
|
363
375
|
containerElement.appendChild(canvasElement);
|
|
364
376
|
}
|
|
365
377
|
|
|
366
|
-
// const canvasElement = document.createElement('canvas');
|
|
367
|
-
// canvasElement.setAttribute('title', `Gif ID - ` + gifId);
|
|
368
|
-
// const canvasContext = canvasElement.getContext('2d');
|
|
369
|
-
// containerElement.appendChild(canvasElement);
|
|
370
|
-
|
|
371
378
|
let spaceElement = document.createElement('div');
|
|
372
379
|
spaceElement.classList.add('space');
|
|
373
380
|
containerElement.appendChild(spaceElement);
|
|
@@ -453,7 +460,7 @@
|
|
|
453
460
|
|
|
454
461
|
let participant;
|
|
455
462
|
|
|
456
|
-
if (settings.participantsHighQuality){
|
|
463
|
+
if (talentKey || settings.participantsHighQuality){
|
|
457
464
|
participant = {
|
|
458
465
|
gifId,
|
|
459
466
|
gifUrl,
|
|
@@ -466,30 +473,31 @@
|
|
|
466
473
|
loginPromise: sdkInstance.auth.deviceLogin(false, gifId),
|
|
467
474
|
session: null, // Will be set after room join
|
|
468
475
|
handRaised: false,
|
|
476
|
+
talentKey,
|
|
469
477
|
};
|
|
470
478
|
|
|
479
|
+
if (talentKey) {
|
|
480
|
+
participant.loginPromise = participant.loginPromise.then(() => sdkInstance.user.updateUserSelf({
|
|
481
|
+
displayname: talents[talentKey].displayname,
|
|
482
|
+
bio: talents[talentKey].bio,
|
|
483
|
+
}));
|
|
484
|
+
}
|
|
485
|
+
|
|
471
486
|
if (settings.fetchNames) {
|
|
472
|
-
participant.loginPromise.then(() => sdkInstance.user.getUserSelf())
|
|
487
|
+
participant.loginPromise = participant.loginPromise.then(() => sdkInstance.user.getUserSelf())
|
|
473
488
|
.then(response => {
|
|
474
489
|
participant.displayname = response.data.displayname;
|
|
475
490
|
participantNameElement.value = response.data.displayname;
|
|
476
491
|
});
|
|
477
|
-
|
|
478
492
|
}
|
|
479
493
|
|
|
480
494
|
elements.participantsList.appendChild(containerElement);
|
|
481
495
|
return Promise.resolve(participant);
|
|
482
|
-
|
|
483
|
-
|
|
484
496
|
} else {
|
|
485
497
|
return fetch(gifUrl)
|
|
486
498
|
.then(response => {
|
|
487
499
|
const imageDecoder = new ImageDecoder({data: response.body, type: 'image/gif'});
|
|
488
500
|
|
|
489
|
-
// if(typeof canvasElement !== "object") {
|
|
490
|
-
// console.log(settings.participantsHighQuality, typeof settings.participantsHighQuality, typeof canvasElement);
|
|
491
|
-
// }
|
|
492
|
-
|
|
493
501
|
participant = {
|
|
494
502
|
gifId,
|
|
495
503
|
gifUrl,
|
|
@@ -508,7 +516,7 @@
|
|
|
508
516
|
};
|
|
509
517
|
|
|
510
518
|
if (settings.fetchNames) {
|
|
511
|
-
participant.loginPromise.then(() => sdkInstance.user.getUserSelf())
|
|
519
|
+
participant.loginPromise = participant.loginPromise.then(() => sdkInstance.user.getUserSelf())
|
|
512
520
|
.then(response => {
|
|
513
521
|
participant.displayname = response.data.displayname;
|
|
514
522
|
participantNameElement.value = response.data.displayname;
|
|
@@ -534,7 +542,6 @@
|
|
|
534
542
|
});
|
|
535
543
|
});
|
|
536
544
|
}
|
|
537
|
-
|
|
538
545
|
}
|
|
539
546
|
|
|
540
547
|
function createParticipants(participantsCount = settings.participantsCount) {
|
|
@@ -565,13 +572,10 @@
|
|
|
565
572
|
});
|
|
566
573
|
}
|
|
567
574
|
|
|
568
|
-
function createSingleParticipant() {
|
|
575
|
+
function createSingleParticipant(talentKey = null) {
|
|
569
576
|
const participantOrder = participants.filter(p => p).length;
|
|
570
577
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
createParticipant(participantOrder)
|
|
578
|
+
createParticipant(participantOrder, talentKey)
|
|
575
579
|
.then(participant => participants[participant.gifId] = participant);
|
|
576
580
|
}
|
|
577
581
|
|
|
@@ -582,6 +586,11 @@
|
|
|
582
586
|
participant.imageDecoder.close();
|
|
583
587
|
}
|
|
584
588
|
|
|
589
|
+
if (participant.talentKey) {
|
|
590
|
+
settings.talentsSelect = settings.talentsSelect.filter(key => key !== participant.talentKey);
|
|
591
|
+
updateTalentsSelectList();
|
|
592
|
+
}
|
|
593
|
+
|
|
585
594
|
participant.sdkInstance.auth.logout();
|
|
586
595
|
usedGifsIds.splice(usedGifsIds.indexOf(participant.gifId), 1);
|
|
587
596
|
document.querySelector('.participant-container[data-participant-id="' + participant.gifId + '"]').remove();
|
|
@@ -597,6 +606,12 @@
|
|
|
597
606
|
if (participant.imageDecoder) {
|
|
598
607
|
participant.imageDecoder.close();
|
|
599
608
|
}
|
|
609
|
+
|
|
610
|
+
if (participant.talentKey) {
|
|
611
|
+
settings.talentsSelect = settings.talentsSelect.filter(key => key !== participant.talentKey);
|
|
612
|
+
updateTalentsSelectList();
|
|
613
|
+
}
|
|
614
|
+
|
|
600
615
|
participant.sdkInstance.auth.logout();
|
|
601
616
|
usedGifsIds.splice(usedGifsIds.indexOf(participant.gifId), 1);
|
|
602
617
|
document.querySelector('.participant-container[data-participant-id="' + participant.gifId + '"]').remove();
|
|
@@ -815,6 +830,38 @@
|
|
|
815
830
|
});
|
|
816
831
|
}
|
|
817
832
|
|
|
833
|
+
function updateTalentsSelectList() {
|
|
834
|
+
elements.form.talentsSelect.innerHTML = "";
|
|
835
|
+
|
|
836
|
+
const infoOptionElement = document.createElement('option');
|
|
837
|
+
infoOptionElement.setAttribute('value', null);
|
|
838
|
+
infoOptionElement.innerHTML = 'Select talent';
|
|
839
|
+
infoOptionElement.disabled = true;
|
|
840
|
+
infoOptionElement.selected = true;
|
|
841
|
+
elements.form.talentsSelect.append(infoOptionElement);
|
|
842
|
+
|
|
843
|
+
Object.keys(talents).forEach(talentKey => {
|
|
844
|
+
const talentName = talents[talentKey].displayname;
|
|
845
|
+
const optionElement = document.createElement('option');
|
|
846
|
+
optionElement.setAttribute('value', 'talent-' + talentKey);
|
|
847
|
+
optionElement.innerHTML = talentName;
|
|
848
|
+
optionElement.disabled = settings.talentsSelect.includes(talentKey);
|
|
849
|
+
elements.form.talentsSelect.append(optionElement);
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function addTalent() {
|
|
854
|
+
const selectedTalentKey = elements.form.talentsSelect.value?.replace('talent-', '');
|
|
855
|
+
|
|
856
|
+
if (selectedTalentKey !== 'null') {
|
|
857
|
+
settings.talentsSelect.push(selectedTalentKey);
|
|
858
|
+
createSingleParticipant(selectedTalentKey);
|
|
859
|
+
setSettingsToUrl();
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
updateTalentsSelectList();
|
|
863
|
+
}
|
|
864
|
+
|
|
818
865
|
// ====================== Initialization ==============================
|
|
819
866
|
|
|
820
867
|
document.addEventListener("DOMContentLoaded", function() {
|
|
@@ -827,6 +874,7 @@
|
|
|
827
874
|
}
|
|
828
875
|
|
|
829
876
|
fillSettingsForm();
|
|
877
|
+
updateTalentsSelectList();
|
|
830
878
|
});
|
|
831
879
|
|
|
832
880
|
</script>
|
|
Binary file
|
package/package.json
CHANGED
package/src/models/asset.js
CHANGED
|
@@ -21,9 +21,9 @@ let asset = function() {
|
|
|
21
21
|
return this.__privates.auth.__client
|
|
22
22
|
.then(client => client.apis.asset.getAssetById({id}))
|
|
23
23
|
},
|
|
24
|
-
updateAsset: ({id, assetType, title, roomIds} = {}) => {
|
|
24
|
+
updateAsset: ({id, assetType, title, roomIds, customAttributes} = {}) => {
|
|
25
25
|
return this.__privates.auth.__client
|
|
26
|
-
.then(client => client.apis.asset.updateAsset({id}, {requestBody:{assetType, title, roomIds}}))
|
|
26
|
+
.then(client => client.apis.asset.updateAsset({id}, {requestBody:{assetType, title, roomIds, customAttributes}}))
|
|
27
27
|
},
|
|
28
28
|
deleteAsset: (id) => {
|
|
29
29
|
return this.__privates.auth.__client
|
package/src/models/room.js
CHANGED
|
@@ -208,11 +208,11 @@ let room = function () {
|
|
|
208
208
|
|
|
209
209
|
},
|
|
210
210
|
|
|
211
|
-
roomRecorder: ({roomId, operation = 'get', config, outputs, destinationIds} = {}) => {
|
|
211
|
+
roomRecorder: ({roomId, operation = 'get', config, outputs, destinationIds, screenWidth, screenHeight} = {}) => {
|
|
212
212
|
return this.__privates.auth.__client
|
|
213
213
|
.then(client => client.apis.wt.recordRoom({}, {
|
|
214
214
|
requestBody: {
|
|
215
|
-
roomId, operation, config, outputs, destinationIds
|
|
215
|
+
roomId, operation, config, outputs, destinationIds, screenWidth, screenHeight
|
|
216
216
|
}
|
|
217
217
|
}))
|
|
218
218
|
},
|