@reactoo/watchtogether-sdk-js 2.4.15 → 2.4.19
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 +122 -56
- package/dist/watchtogether-sdk.min.js +2 -2
- package/package.json +5 -5
- package/src/models/auth.js +2 -2
- package/src/models/room-session.js +4 -4
- package/src/modules/sync-modules/sync-dash-vod.js +23 -10
- package/src/modules/sync-modules/sync-hls-vod.js +23 -10
- package/src/modules/sync-modules/sync-native-hls-vod.js +23 -10
- package/src/modules/sync-modules/sync-shaka-dash-vod.js +23 -10
- package/src/modules/wt-room.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactoo/watchtogether-sdk-js",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.19",
|
|
4
4
|
"description": "Javascript SDK for Reactoo",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"unpkg": "dist/watchtogether-sdk.min.js",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/picitujeromanov/WR-SDK",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.15.
|
|
28
|
+
"@babel/core": "^7.15.8",
|
|
29
29
|
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
|
30
30
|
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
|
|
31
|
-
"@babel/plugin-proposal-private-property-in-object": "^7.
|
|
32
|
-
"@babel/preset-env": "^7.15.
|
|
31
|
+
"@babel/plugin-proposal-private-property-in-object": "^7.15.4",
|
|
32
|
+
"@babel/preset-env": "^7.15.8",
|
|
33
33
|
"acorn": "^6.4.2",
|
|
34
34
|
"babel-core": "^6.26.3",
|
|
35
35
|
"babel-loader": "^8.2.2",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"aws-iot-device-sdk": "^2.2.11",
|
|
47
47
|
"paho-mqtt": "^1.1.0",
|
|
48
48
|
"serialize-error": "^7.0.1",
|
|
49
|
-
"swagger-client": "^3.16.
|
|
49
|
+
"swagger-client": "^3.16.1",
|
|
50
50
|
"webrtc-adapter": "^7.7.1"
|
|
51
51
|
},
|
|
52
52
|
"browserslist": [
|
package/src/models/auth.js
CHANGED
|
@@ -14,14 +14,14 @@ let auth = function () {
|
|
|
14
14
|
})
|
|
15
15
|
},
|
|
16
16
|
|
|
17
|
-
providerLogin: (domain, token, displayname) => {
|
|
17
|
+
providerLogin: (domain, token, displayname, deviceId) => {
|
|
18
18
|
|
|
19
19
|
if(!token && typeof this.__privates.providerAuth === 'function') {
|
|
20
20
|
({token, displayname} = this.__privates.providerAuth());
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
return this.__privates.auth.__client
|
|
24
|
-
.then(client => client.apis.auth.providerSignIn({},{requestBody:{domain, token, ...(displayname !== null && {
|
|
24
|
+
.then(client => client.apis.auth.providerSignIn({},{requestBody:{domain, token, ...(displayname && {displayname}), ...(deviceId !== null && {deviceId})}}))
|
|
25
25
|
.then(response => {
|
|
26
26
|
this.userId = response.data.userId;
|
|
27
27
|
this.username = response.data.username;
|
|
@@ -83,7 +83,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
83
83
|
isInstructor
|
|
84
84
|
}), wt.user.getUserSelf()])
|
|
85
85
|
.then(([roomData, userData]) => Promise.all([roomData, userData, this.setRoomVars()]))
|
|
86
|
-
.then(([roomData, userData, _]) => room.connect(roomData.data.roomId, roomData.data.pin, roomData.data.href, roomData.data.iceServers, roomData.data.accessToken, (isMonitor || isInstructor) ? roomData.data.userId : userData.data._id, roomData.data.webrtcVersion, (roomData.data.bitrate ? parseInt(roomData.data.bitrate) : 0), isMonitor, roomData.data.recordingFilename))
|
|
86
|
+
.then(([roomData, userData, _]) => room.connect(roomData.data.roomId, roomData.data.pin, roomData.data.href, roomData.data.iceServers, roomData.data.accessToken, (isMonitor || isInstructor || isTalkback) ? roomData.data.userId : userData.data._id, roomData.data.webrtcVersion, (roomData.data.bitrate ? parseInt(roomData.data.bitrate) : 0), isMonitor, roomData.data.recordingFilename))
|
|
87
87
|
.finally(() => {
|
|
88
88
|
emitter.emit('connecting', false);
|
|
89
89
|
})
|
|
@@ -351,11 +351,11 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
351
351
|
},
|
|
352
352
|
|
|
353
353
|
unpublishLocal: () => {
|
|
354
|
-
return room.unpublishLocal()
|
|
354
|
+
return room.unpublishLocal();
|
|
355
355
|
},
|
|
356
356
|
|
|
357
|
-
toggleAudio: () => {
|
|
358
|
-
return room.toggleAudio()
|
|
357
|
+
toggleAudio: (value) => {
|
|
358
|
+
return room.toggleAudio(value);
|
|
359
359
|
},
|
|
360
360
|
|
|
361
361
|
toggleVideo: () => {
|
|
@@ -207,19 +207,32 @@ const syncVodDashJs = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
207
207
|
}
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
const
|
|
210
|
+
const executePlayerIotEvents = (data) => {
|
|
211
211
|
let rid = _roomId || room.roomId;
|
|
212
|
+
if(data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
|
|
213
|
+
seekTo(0).then(() => playMedia());
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if(data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
|
|
217
|
+
playMedia();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if(data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
|
|
221
|
+
pauseMedia();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const parseIotEvents = (data) => {
|
|
212
226
|
if(data.event === 'template_updated') {
|
|
213
|
-
if(data.operation === '
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
227
|
+
if(data.operation === 'multi') {
|
|
228
|
+
(data.value || []).forEach(event => {
|
|
229
|
+
if (event.operation === 'sendMessage') {
|
|
230
|
+
executePlayerIotEvents({...data, roomId: data.roomId, userId: data.userId});
|
|
231
|
+
}
|
|
232
|
+
})
|
|
219
233
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
pauseMedia();
|
|
234
|
+
if(data.operation === 'sendMessage') {
|
|
235
|
+
executePlayerIotEvents(data);
|
|
223
236
|
}
|
|
224
237
|
}
|
|
225
238
|
};
|
|
@@ -207,19 +207,32 @@ const syncVodHlsJs = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
207
207
|
}
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
const
|
|
210
|
+
const executePlayerIotEvents = (data) => {
|
|
211
211
|
let rid = _roomId || room.roomId;
|
|
212
|
+
if(data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
|
|
213
|
+
seekTo(0).then(() => playMedia());
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if(data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
|
|
217
|
+
playMedia();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if(data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
|
|
221
|
+
pauseMedia();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const parseIotEvents = (data) => {
|
|
212
226
|
if(data.event === 'template_updated') {
|
|
213
|
-
if(data.operation === '
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
227
|
+
if(data.operation === 'multi') {
|
|
228
|
+
(data.value || []).forEach(event => {
|
|
229
|
+
if (event.operation === 'sendMessage') {
|
|
230
|
+
executePlayerIotEvents({...data, roomId: data.roomId, userId: data.userId});
|
|
231
|
+
}
|
|
232
|
+
})
|
|
219
233
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
pauseMedia();
|
|
234
|
+
if(data.operation === 'sendMessage') {
|
|
235
|
+
executePlayerIotEvents(data);
|
|
223
236
|
}
|
|
224
237
|
}
|
|
225
238
|
};
|
|
@@ -199,19 +199,32 @@ const syncVodHlsJs = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
199
199
|
return room._isDataChannelOpen && room._hasJoined;
|
|
200
200
|
};
|
|
201
201
|
|
|
202
|
-
const
|
|
202
|
+
const executePlayerIotEvents = (data) => {
|
|
203
203
|
let rid = _roomId || room.roomId;
|
|
204
|
+
if(data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
|
|
205
|
+
seekTo(0).then(() => playMedia());
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if(data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
|
|
209
|
+
playMedia();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if(data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
|
|
213
|
+
pauseMedia();
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const parseIotEvents = (data) => {
|
|
204
218
|
if(data.event === 'template_updated') {
|
|
205
|
-
if(data.operation === '
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
219
|
+
if(data.operation === 'multi') {
|
|
220
|
+
(data.value || []).forEach(event => {
|
|
221
|
+
if (event.operation === 'sendMessage') {
|
|
222
|
+
executePlayerIotEvents({...data, roomId: data.roomId, userId: data.userId});
|
|
223
|
+
}
|
|
224
|
+
})
|
|
211
225
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
pauseMedia();
|
|
226
|
+
if(data.operation === 'sendMessage') {
|
|
227
|
+
executePlayerIotEvents(data);
|
|
215
228
|
}
|
|
216
229
|
}
|
|
217
230
|
};
|
|
@@ -205,19 +205,32 @@ const syncVodShakaDash = function ({room, wt, roomSession, emitter} = {}) {
|
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
-
const
|
|
208
|
+
const executePlayerIotEvents = (data) => {
|
|
209
209
|
let rid = _roomId || room.roomId;
|
|
210
|
+
if(data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
|
|
211
|
+
seekTo(0).then(() => playMedia());
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if(data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
|
|
215
|
+
playMedia();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if(data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
|
|
219
|
+
pauseMedia();
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const parseIotEvents = (data) => {
|
|
210
224
|
if(data.event === 'template_updated') {
|
|
211
|
-
if(data.operation === '
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
225
|
+
if(data.operation === 'multi') {
|
|
226
|
+
(data.value || []).forEach(event => {
|
|
227
|
+
if (event.operation === 'sendMessage') {
|
|
228
|
+
executePlayerIotEvents({...data, roomId: data.roomId, userId: data.userId});
|
|
229
|
+
}
|
|
230
|
+
})
|
|
217
231
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
pauseMedia();
|
|
232
|
+
if(data.operation === 'sendMessage') {
|
|
233
|
+
executePlayerIotEvents(data);
|
|
221
234
|
}
|
|
222
235
|
}
|
|
223
236
|
};
|
package/src/modules/wt-room.js
CHANGED
|
@@ -2005,7 +2005,7 @@ class RoomSession {
|
|
|
2005
2005
|
: Promise.resolve()
|
|
2006
2006
|
}
|
|
2007
2007
|
|
|
2008
|
-
toggleAudio() {
|
|
2008
|
+
toggleAudio(value = null) {
|
|
2009
2009
|
let handle = this._getHandle(this.handleId);
|
|
2010
2010
|
if (!handle) {
|
|
2011
2011
|
return Promise.reject({type: 'error', id: 21, message: 'no local id, connect first', data: null})
|
|
@@ -2015,12 +2015,12 @@ class RoomSession {
|
|
|
2015
2015
|
let transceiver = config.pc.getTransceivers()
|
|
2016
2016
|
.find(t => t.sender && t.sender.track && t.receiver.track.kind === "audio" && t.stopped === false);
|
|
2017
2017
|
if (transceiver) {
|
|
2018
|
-
transceiver.sender.track.enabled = !transceiver.sender.track.enabled;
|
|
2018
|
+
transceiver.sender.track.enabled = value !== null ? !!value : !transceiver.sender.track.enabled;
|
|
2019
2019
|
}
|
|
2020
2020
|
this.isAudioMuted = !transceiver || !transceiver.sender.track.enabled;
|
|
2021
2021
|
} else {
|
|
2022
2022
|
if (config.stream && config.stream.getAudioTracks().length) {
|
|
2023
|
-
config.stream.getAudioTracks()[0].enabled = !config.stream.getAudioTracks()[0].enabled;
|
|
2023
|
+
config.stream.getAudioTracks()[0].enabled = value !== null ? !!value : !config.stream.getAudioTracks()[0].enabled;
|
|
2024
2024
|
}
|
|
2025
2025
|
this.isAudioMuted = config.stream.getAudioTracks().length === 0 || !config.stream.getAudioTracks()[0].enabled;
|
|
2026
2026
|
}
|