@reactoo/watchtogether-sdk-js 2.5.56 → 2.5.59
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
|
@@ -7,6 +7,7 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
7
7
|
let _emitter = localEmitter();
|
|
8
8
|
|
|
9
9
|
let _playerInterface = null;
|
|
10
|
+
let _propagateMaster = false;
|
|
10
11
|
let _playerInterfaceOptions = {
|
|
11
12
|
type: 'none',
|
|
12
13
|
ignoreBufferedTimeRanges: true,
|
|
@@ -14,7 +15,7 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
14
15
|
};
|
|
15
16
|
const syncDefaultWaitTime = 60000;
|
|
16
17
|
const syncShortWaitTime = 10000;
|
|
17
|
-
const maxSyncThreshold = 0.
|
|
18
|
+
const maxSyncThreshold = 0.4;
|
|
18
19
|
const maxSyncTries = 3;
|
|
19
20
|
const waitForPlayingEventAfterSeek = 5000;
|
|
20
21
|
const fastForwardThreshold = 4
|
|
@@ -28,7 +29,6 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
28
29
|
let isPlaying = false;
|
|
29
30
|
let isPreloading = true;
|
|
30
31
|
let isProgrammaticallySeeked = false;
|
|
31
|
-
let shouldPropagateMaster = false;
|
|
32
32
|
|
|
33
33
|
const startSyncLoop = () => {
|
|
34
34
|
|
|
@@ -117,7 +117,7 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
117
117
|
return Promise.resolve();
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
else if(
|
|
120
|
+
else if(_propagateMaster) {
|
|
121
121
|
setNextWaitTime(false);
|
|
122
122
|
return propagateMasterFunc();
|
|
123
123
|
}
|
|
@@ -134,7 +134,7 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
134
134
|
return Promise.resolve();
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
if(position !== null) {
|
|
137
|
+
if(position !== null && !isNaN(position)) {
|
|
138
138
|
return seekBy(position)
|
|
139
139
|
.then(() => {
|
|
140
140
|
const seekDuration = (Date.now() - syncStartTime) / 1000;
|
|
@@ -142,7 +142,7 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
142
142
|
? _playerInterface.getTimeDifference(syncData.masterFragmentSn, syncData.masterFragmentPos, syncData.ping)
|
|
143
143
|
: getTimeDifference(syncData.masterFragmentSn, syncData.masterFragmentPos, syncData.ping);
|
|
144
144
|
|
|
145
|
-
const syncPrecision = Math.abs(realPosition
|
|
145
|
+
const syncPrecision = Math.abs(realPosition);
|
|
146
146
|
room._log(`Insufficient buffer: `, !isBufferSufficient)
|
|
147
147
|
room._log(`Seek duration is ${seekDuration} seconds`);
|
|
148
148
|
room._log(`Sync precision should be ${syncPrecision}`);
|
|
@@ -152,22 +152,25 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
152
152
|
return Promise.resolve();
|
|
153
153
|
})
|
|
154
154
|
.catch((e) => {
|
|
155
|
+
room._log(`Seek failed: `, e);
|
|
155
156
|
setNextWaitTime(true);
|
|
156
157
|
return Promise.reject(e);
|
|
157
158
|
});
|
|
158
159
|
} else {
|
|
160
|
+
room._log(`Position in not a number: `, position);
|
|
159
161
|
setNextWaitTime(true);
|
|
160
162
|
return Promise.reject();
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
|
-
}).catch(() => {
|
|
165
|
+
}).catch((e) => {
|
|
166
|
+
room._log(`getSyncData() failed: `, e);
|
|
164
167
|
setNextWaitTime(true);
|
|
165
168
|
return Promise.reject();
|
|
166
169
|
})
|
|
167
170
|
}
|
|
168
171
|
|
|
169
172
|
const handleAddLocalParticipant = () => {
|
|
170
|
-
if(
|
|
173
|
+
if(_propagateMaster) {
|
|
171
174
|
propagateMasterFunc();
|
|
172
175
|
}
|
|
173
176
|
if(_playerInterface.isPaused === false) {
|
|
@@ -176,7 +179,7 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
176
179
|
};
|
|
177
180
|
|
|
178
181
|
const handleAddRemoteParticipant = () => {
|
|
179
|
-
if(
|
|
182
|
+
if(_propagateMaster) {
|
|
180
183
|
propagateMasterFunc();
|
|
181
184
|
}
|
|
182
185
|
};
|
|
@@ -516,15 +519,17 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
516
519
|
|
|
517
520
|
__events: ['playerSyncing'],
|
|
518
521
|
|
|
519
|
-
initialize: (playerInterface) => {
|
|
522
|
+
initialize: ({playerInterface, propagateMaster = false} = {}) => {
|
|
520
523
|
|
|
521
524
|
_playerInterface = playerInterface;
|
|
522
525
|
_playerInterfaceOptions = {..._playerInterfaceOptions, ...(_playerInterface.syncSettings || {})}
|
|
523
|
-
|
|
526
|
+
_propagateMaster = propagateMaster;
|
|
527
|
+
|
|
524
528
|
room._log('Interface options passed: ', (_playerInterface.syncSettings || {}));
|
|
525
529
|
room._log('All interface options: ', _playerInterfaceOptions );
|
|
526
530
|
|
|
527
531
|
if(_playerInterfaceOptions.type === 'none') {
|
|
532
|
+
room._log('Sync module has been disabled via type:none');
|
|
528
533
|
return;
|
|
529
534
|
}
|
|
530
535
|
|
|
@@ -557,9 +562,6 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
557
562
|
_emitter.emit('timeupdate', event);
|
|
558
563
|
}
|
|
559
564
|
});
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
shouldPropagateMaster = false;
|
|
563
565
|
|
|
564
566
|
isPlaying = _playerInterface.isPaused === false;
|
|
565
567
|
|
|
@@ -569,7 +571,7 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
569
571
|
room.on('addRemoteParticipant', handleAddRemoteParticipant);
|
|
570
572
|
room.on('data', parseDataEvents);
|
|
571
573
|
|
|
572
|
-
if(
|
|
574
|
+
if(_propagateMaster) {
|
|
573
575
|
propagateMasterFunc().catch(() => {});
|
|
574
576
|
}
|
|
575
577
|
|
|
@@ -580,8 +582,7 @@ const syncModule = function ({room, emitter} = {}) {
|
|
|
580
582
|
_emitter.on('buffering', handleBuffering);
|
|
581
583
|
_emitter.on('playing', handlePlaying);
|
|
582
584
|
_emitter.on('pause', handlePause);
|
|
583
|
-
|
|
584
|
-
|
|
585
|
+
|
|
585
586
|
},
|
|
586
587
|
|
|
587
588
|
destroy: () => {
|