@reactoo/watchtogether-sdk-js 2.5.60 → 2.5.63

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.60",
3
+ "version": "2.5.63",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -184,11 +184,15 @@ let roomSession = function ({roomId, pinHash, role}, room, wt) {
184
184
  } else if (msg.user_action === 'chat_message') {
185
185
  emitter.emit('chatMessage', msg);
186
186
  } else if (msg.user_action === 'remote_muted') {
187
- if (msg.from !== room.userId) {
188
- emitter.emit('remoteMuted', {userId: decodeJanusDisplay(msg.from)?.userId, ...(msg.text && JSON.parse(msg.text))})
187
+ const fromUserId = decodeJanusDisplay(msg.from)?.userId;
188
+ const ownUserId = decodeJanusDisplay(room.userId)?.userId;
189
+ if (fromUserId !== ownUserId) {
190
+ emitter.emit('remoteMuted', {role: decodeJanusDisplay(msg.from)?.role, userId: decodeJanusDisplay(msg.from)?.userId, ...(msg.text && JSON.parse(msg.text))})
189
191
  }
190
192
  } else if (msg.user_action === 'remote_muted_request') {
191
- if (msg.from !== room.userId) {
193
+ const fromUserId = decodeJanusDisplay(msg.from)?.userId;
194
+ const ownUserId = decodeJanusDisplay(room.userId)?.userId;
195
+ if (fromUserId !== ownUserId) {
192
196
  this.__sendMuteStatus();
193
197
  }
194
198
  }
@@ -15,7 +15,7 @@ const syncModule = function ({room, emitter} = {}) {
15
15
  };
16
16
  const syncDefaultWaitTime = 60000;
17
17
  const syncShortWaitTime = 10000;
18
- const maxSyncThreshold = 0.4;
18
+ const maxSyncThreshold = 0.5;
19
19
  const maxSyncTries = 3;
20
20
  const waitForPlayingEventAfterSeek = 5000;
21
21
  const fastForwardThreshold = 4
@@ -71,11 +71,13 @@ const syncModule = function ({room, emitter} = {}) {
71
71
 
72
72
  };
73
73
 
74
- const stopSyncLoop = () => {
74
+ const stopSyncLoop = (doNotResetRetryCount) => {
75
75
  room._log('--- Sync disabled ---');
76
76
  clearTimeout(syncWaitId);
77
77
  syncWaitId = null;
78
- currentSyncRetry = 0
78
+ if(!doNotResetRetryCount) {
79
+ currentSyncRetry = 0
80
+ }
79
81
  stopFlag = true;
80
82
  };
81
83
 
@@ -137,14 +139,14 @@ const syncModule = function ({room, emitter} = {}) {
137
139
  if(position !== null && !isNaN(position)) {
138
140
  return seekBy(position)
139
141
  .then(() => {
140
- const seekDuration = (Date.now() - syncStartTime) / 1000;
142
+ const seekDuration = (Date.now() - syncStartTime);
141
143
  const {position, realPosition, isBufferSufficient} = _playerInterface.getTimeDifference
142
144
  ? _playerInterface.getTimeDifference(syncData.masterFragmentSn, syncData.masterFragmentPos + seekDuration, syncData.ping)
143
145
  : getTimeDifference(syncData.masterFragmentSn, syncData.masterFragmentPos + seekDuration, syncData.ping);
144
146
 
145
147
  const syncPrecision = Math.abs(realPosition);
146
148
  room._log(`Insufficient buffer: `, !isBufferSufficient)
147
- room._log(`Seek duration is ${seekDuration} seconds`);
149
+ room._log(`Seek duration is ${seekDuration / 1000} seconds`);
148
150
  room._log(`Sync precision should be ${syncPrecision}`);
149
151
 
150
152
  const didSyncFail = syncPrecision > maxSyncThreshold;
@@ -374,7 +376,7 @@ const syncModule = function ({room, emitter} = {}) {
374
376
  const handleBuffering = () => {
375
377
  room._log('handleBuffering');
376
378
  if(!isProgrammaticallySeeked) {
377
- stopSyncLoop();
379
+ stopSyncLoop(true);
378
380
  clientPaused().catch(() => {});
379
381
  isPreloading = _playerInterface.isPaused;
380
382
  }