@reactoo/watchtogether-sdk-js 2.5.69 → 2.5.72

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.5.69",
3
+ "version": "2.5.72",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -33,7 +33,7 @@ const syncModule = function ({room, emitter} = {}) {
33
33
 
34
34
  const startSyncLoop = () => {
35
35
 
36
- if(!isConnected()) {
36
+ if(!isConnected() && _playerInterfaceOptions.type !== 'push') {
37
37
  room._log('--- Sync loop will not start due to user not connected yet ---');
38
38
  return
39
39
  }
@@ -46,45 +46,45 @@ const syncModule = function ({room, emitter} = {}) {
46
46
  room._log('--- Sync enabled ---');
47
47
 
48
48
  stopFlag = false;
49
-
50
- const loop = () => {
51
-
52
- isSyncing = true;
53
- emitter.emit('playerSyncing', true);
54
-
55
- sync().finally(() => {
56
-
57
- isSyncing = false;
58
- emitter.emit('playerSyncing', false);
59
-
60
- if(isConnected() && !stopFlag) {
61
- syncWaitId = setTimeout(loop, syncNextWaitTime);
62
- }
63
- else {
64
- room._log('--- Automatic stop due to user not connected or stop flag enabled ---');
65
- stopSyncLoop();
66
- }
67
-
68
- })
69
- };
70
-
71
- loop();
72
49
 
73
- //TODO: push sync
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
- //
86
- // loop2();
87
-
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
88
  };
89
89
 
90
90
  const stopSyncLoop = (doNotResetRetryCount) => {
@@ -262,7 +262,7 @@ const syncModule = function ({room, emitter} = {}) {
262
262
  reject('Stalled');
263
263
  };
264
264
 
265
- console.log('Users stream is behind behind live by:',diff);
265
+ console.log('Users stream is behind behind live by:', diff);
266
266
  if(diff_target > 0) {
267
267
  _emitter.once('stalled', __);
268
268
  setExactTimeout(() => {
@@ -271,7 +271,7 @@ const syncModule = function ({room, emitter} = {}) {
271
271
  isSyncing = false;
272
272
  _emitter.off('stalled', __);
273
273
  resolve();
274
- }, (diff_target * 1000) / playbackRate, 20);
274
+ }, (diff_target * 1000) / (playbackRate - 1), 20);
275
275
  isProgrammaticallySeeked = true;
276
276
  isSyncing = true;
277
277
  _playerInterface.setPlaybackRate(playbackRate);
@@ -582,10 +582,10 @@ const syncModule = function ({room, emitter} = {}) {
582
582
  return;
583
583
  }
584
584
 
585
- if(_playerInterfaceOptions.type === 'push') {
586
- room._log('Push sync is not implemented in this sync module yet');
587
- return;
588
- }
585
+ // if(_playerInterfaceOptions.type === 'push') {
586
+ // room._log('Push sync is not implemented in this sync module yet');
587
+ // return;
588
+ // }
589
589
 
590
590
  if(_playerInterface.isVod) {
591
591
  room._log('VOD sync is not implemented in this sync module yet');