@reactoo/watchtogether-sdk-js 2.5.68 → 2.5.71
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/package.json
CHANGED
|
@@ -24,12 +24,13 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
24
24
|
let syncNextWaitTime = null;
|
|
25
25
|
let stopFlag = false;
|
|
26
26
|
let isSyncing = false;
|
|
27
|
-
|
|
27
|
+
let safeSpace = 2;
|
|
28
28
|
let playbackRate = 2;
|
|
29
29
|
let isPlaying = false;
|
|
30
30
|
let isPreloading = true;
|
|
31
31
|
let isProgrammaticallySeeked = false;
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
|
|
33
34
|
const startSyncLoop = () => {
|
|
34
35
|
|
|
35
36
|
if(!isConnected()) {
|
|
@@ -45,29 +46,49 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
45
46
|
room._log('--- Sync enabled ---');
|
|
46
47
|
|
|
47
48
|
stopFlag = false;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
49
|
+
|
|
50
|
+
if(!_playerInterfaceOptions.type === 'push') {
|
|
51
|
+
const loop = () => {
|
|
52
|
+
|
|
53
|
+
isSyncing = true;
|
|
54
|
+
emitter.emit('playerSyncing', true);
|
|
55
|
+
|
|
56
|
+
sync().finally(() => {
|
|
57
|
+
|
|
58
|
+
isSyncing = false;
|
|
59
|
+
emitter.emit('playerSyncing', false);
|
|
60
|
+
|
|
61
|
+
if(isConnected() && !stopFlag) {
|
|
62
|
+
syncWaitId = setTimeout(loop, syncNextWaitTime);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
room._log('--- Automatic stop due to user not connected or stop flag enabled ---');
|
|
66
|
+
stopSyncLoop();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
})
|
|
70
|
+
};
|
|
71
|
+
loop();
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const loop2 = () => {
|
|
75
|
+
seekForward()
|
|
76
|
+
.then(() => {
|
|
77
|
+
setNextWaitTime(false);
|
|
78
|
+
})
|
|
79
|
+
.catch((e) => {
|
|
80
|
+
setNextWaitTime(true);
|
|
81
|
+
console.log('Sync failed', e);
|
|
82
|
+
});
|
|
83
|
+
syncWaitId = setTimeout(loop2, syncNextWaitTime);
|
|
84
|
+
};
|
|
85
|
+
loop2();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
//TODO: push sync
|
|
91
|
+
|
|
71
92
|
|
|
72
93
|
};
|
|
73
94
|
|
|
@@ -234,6 +255,37 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
234
255
|
}
|
|
235
256
|
};
|
|
236
257
|
|
|
258
|
+
const seekForward = () => {
|
|
259
|
+
return new Promise((resolve, reject) => {
|
|
260
|
+
let diff = _playerInterface.buffered.end(0) - _playerInterface.currentTime;
|
|
261
|
+
let diff_target = diff - safeSpace;
|
|
262
|
+
|
|
263
|
+
let __ = () => {
|
|
264
|
+
_playerInterface.setPlaybackRate(1);
|
|
265
|
+
isProgrammaticallySeeked = false;
|
|
266
|
+
isSyncing = false;
|
|
267
|
+
reject('Stalled');
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
console.log('Users stream is behind behind live by:', diff);
|
|
271
|
+
if(diff_target > 0) {
|
|
272
|
+
_emitter.once('stalled', __);
|
|
273
|
+
setExactTimeout(() => {
|
|
274
|
+
_playerInterface.setPlaybackRate(1);
|
|
275
|
+
isProgrammaticallySeeked = false;
|
|
276
|
+
isSyncing = false;
|
|
277
|
+
_emitter.off('stalled', __);
|
|
278
|
+
resolve();
|
|
279
|
+
}, (diff_target * 1000) / (playbackRate - 1), 20);
|
|
280
|
+
isProgrammaticallySeeked = true;
|
|
281
|
+
isSyncing = true;
|
|
282
|
+
_playerInterface.setPlaybackRate(playbackRate);
|
|
283
|
+
} else {
|
|
284
|
+
resolve();
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
|
|
237
289
|
const seekBy = (time) => {
|
|
238
290
|
return new Promise((resolve, reject) => {
|
|
239
291
|
if(_playerInterface.currentTime !== time) {
|
|
@@ -535,10 +587,10 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
535
587
|
return;
|
|
536
588
|
}
|
|
537
589
|
|
|
538
|
-
if(_playerInterfaceOptions.type === 'push') {
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
590
|
+
// if(_playerInterfaceOptions.type === 'push') {
|
|
591
|
+
// room._log('Push sync is not implemented in this sync module yet');
|
|
592
|
+
// return;
|
|
593
|
+
// }
|
|
542
594
|
|
|
543
595
|
if(_playerInterface.isVod) {
|
|
544
596
|
room._log('VOD sync is not implemented in this sync module yet');
|
package/src/modules/wt-iot.js
CHANGED
|
@@ -163,7 +163,7 @@ class Iot {
|
|
|
163
163
|
if(payload.display) {
|
|
164
164
|
const decodedDisplay = decodeJanusDisplay(payload.display);
|
|
165
165
|
if(decodedDisplay.userId) {
|
|
166
|
-
payload = {...payload, userId: decodedDisplay.userId, role: decodedDisplay.role};
|
|
166
|
+
payload = {...payload, userId: decodedDisplay.userId, role: decodedDisplay.role, start: decodedDisplay.start};
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|