@reactoo/watchtogether-sdk-js 2.5.21 → 2.5.24
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.html +31 -2
- package/package.json +1 -1
- package/src/modules/sync-modules/sync-hls.js +2 -2
- package/src/modules/sync-modules/sync-universal.js +1 -1
- package/src/modules/wt-room.js +219 -198
|
@@ -19,7 +19,12 @@
|
|
|
19
19
|
<!--<br><br>-->
|
|
20
20
|
|
|
21
21
|
<label for="room-id">Room ID</label><br>
|
|
22
|
-
<input type="text" id="room-id" placeholder="
|
|
22
|
+
<input type="text" id="room-id" placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" size="40">
|
|
23
|
+
|
|
24
|
+
<br><br>
|
|
25
|
+
|
|
26
|
+
<label for="pin-hash">Pin Hash</label><br>
|
|
27
|
+
<input type="text" id="pin-hash" placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" size="40">
|
|
23
28
|
|
|
24
29
|
<br><br>
|
|
25
30
|
|
|
@@ -48,6 +53,7 @@
|
|
|
48
53
|
let participantsCount = 3;
|
|
49
54
|
let instanceType = "reactooDemo";
|
|
50
55
|
let roomId = "0512f218-6a4a-45e1-9d05-d5a0e5afb33d";
|
|
56
|
+
let pinHash = undefined;
|
|
51
57
|
let timeoutBetweenParticipantsJoins = 5000;
|
|
52
58
|
|
|
53
59
|
let participantsData = null;
|
|
@@ -65,8 +71,17 @@
|
|
|
65
71
|
participantsCount = parseInt(document.getElementById('users-count').value);
|
|
66
72
|
// instanceType = document.getElementById('instance-type').value;
|
|
67
73
|
roomId = document.getElementById('room-id').value;
|
|
74
|
+
pinHash = document.getElementById('pin-hash').value;
|
|
68
75
|
timeoutBetweenParticipantsJoins = document.getElementById('connection-timeout').value;
|
|
69
76
|
|
|
77
|
+
const url = new URL(location.href);
|
|
78
|
+
participantsCount ? url.searchParams.set('participantsCount', participantsCount) : url.searchParams.delete('participantsCount');
|
|
79
|
+
// instanceType ? url.searchParams.set('instanceType', instanceType) : url.searchParams.delete('instanceType');
|
|
80
|
+
roomId ? url.searchParams.set('roomId', roomId) : url.searchParams.delete('roomId');
|
|
81
|
+
pinHash ? url.searchParams.set('pinHash', pinHash) : url.searchParams.delete('pinHash');
|
|
82
|
+
timeoutBetweenParticipantsJoins ? url.searchParams.set('timeoutBetweenParticipantsJoins', timeoutBetweenParticipantsJoins) : url.searchParams.delete('timeoutBetweenParticipantsJoins');
|
|
83
|
+
history.replaceState (null, '', url);
|
|
84
|
+
|
|
70
85
|
document.getElementById('join-room').setAttribute('disabled', true);
|
|
71
86
|
document.getElementById('joined-participants-count').value = joinedParticipantsCount;
|
|
72
87
|
|
|
@@ -169,7 +184,7 @@
|
|
|
169
184
|
|
|
170
185
|
function joinRoom(participantData) {
|
|
171
186
|
return participantData.sdkInstance.auth.deviceLogin(participantData.id)
|
|
172
|
-
.then(() => participantData.sdkInstance.room.createSession({roomId}))
|
|
187
|
+
.then(() => participantData.sdkInstance.room.createSession({roomId, pinHash}))
|
|
173
188
|
.then(session => {
|
|
174
189
|
participantData.session = session;
|
|
175
190
|
return Promise.all([session, session.connect()])
|
|
@@ -182,10 +197,24 @@
|
|
|
182
197
|
return participantData.session.disconnect();
|
|
183
198
|
}
|
|
184
199
|
|
|
200
|
+
function getQueryVar(varName){
|
|
201
|
+
const queryStr = decodeURI(window.location.search) + '&';
|
|
202
|
+
const regex = new RegExp('.*?[&\\?]' + varName + '=(.*?)&.*');
|
|
203
|
+
const val = queryStr.replace(regex, "$1");
|
|
204
|
+
return val === queryStr ? false : val;
|
|
205
|
+
}
|
|
206
|
+
|
|
185
207
|
document.addEventListener("DOMContentLoaded", function() {
|
|
208
|
+
participantsCount = getQueryVar('participantsCount') || participantsCount;
|
|
209
|
+
// instanceType = getQueryVar('instanceType') || instanceType;
|
|
210
|
+
roomId = getQueryVar('roomId') || roomId;
|
|
211
|
+
pinHash = getQueryVar('pinHash') || pinHash || '';
|
|
212
|
+
timeoutBetweenParticipantsJoins = getQueryVar('timeoutBetweenParticipantsJoins') || timeoutBetweenParticipantsJoins;
|
|
213
|
+
|
|
186
214
|
document.getElementById('users-count').value = participantsCount;
|
|
187
215
|
// document.getElementById('instance-type').value = instanceType;
|
|
188
216
|
document.getElementById('room-id').value = roomId;
|
|
217
|
+
document.getElementById('pin-hash').value = pinHash;
|
|
189
218
|
document.getElementById('connection-timeout').value = timeoutBetweenParticipantsJoins;
|
|
190
219
|
});
|
|
191
220
|
|
package/package.json
CHANGED
|
@@ -228,7 +228,7 @@ const syncHlsJs = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
228
228
|
if(!currentFragment) {
|
|
229
229
|
return 0;
|
|
230
230
|
}
|
|
231
|
-
return Math.max((_libraryInstance.streamController.lastCurrentTime - currentFragment.body
|
|
231
|
+
return Math.max((_libraryInstance.streamController.lastCurrentTime - (currentFragment.body?.startPTS || 0)) * 1000, 0)
|
|
232
232
|
};
|
|
233
233
|
|
|
234
234
|
const calculateSyncDifferenceTime = (masterFragmentSn, masterFragmentPos, ping) => {
|
|
@@ -245,7 +245,7 @@ const syncHlsJs = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
245
245
|
return {position: null, isBufferSufficient: false}
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
let currentFragmentPos = Math.max((_libraryInstance.streamController.lastCurrentTime - currentFragment.body
|
|
248
|
+
let currentFragmentPos = Math.max((_libraryInstance.streamController.lastCurrentTime - (currentFragment.body?.startPTS || 0)) * 1000, 0);
|
|
249
249
|
let currentFragmentLength = currentFragment.body.duration * 1000;
|
|
250
250
|
|
|
251
251
|
room._log(`Our current fragment is: ${currentFragmentSn}`);
|
|
@@ -339,7 +339,7 @@ const syncUniversal = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
339
339
|
timestamp: new Date().getTime(),
|
|
340
340
|
fragment: String("0"),
|
|
341
341
|
fragment_pos: Number(fragmentPosition),
|
|
342
|
-
slave_id:Number(slaveId)
|
|
342
|
+
slave_id: Number(slaveId)
|
|
343
343
|
}});
|
|
344
344
|
};
|
|
345
345
|
|