@reactoo/watchtogether-sdk-js 2.5.16 → 2.5.18
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 +3 -3
- package/dist/watchtogether-sdk.min.js +2 -2
- package/example/audio_controls/audio_controls.html +2 -2
- package/example/audio_controls/audiocontrols.js +17 -4
- package/example/index.html +12 -23
- package/package.json +1 -1
- package/src/models/room-session.js +3 -3
- package/src/modules/wt-room.js +161 -213
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
attack: 0.001,
|
|
70
70
|
release: 0.15,
|
|
71
71
|
speed: "medium"
|
|
72
|
-
}
|
|
72
|
+
},
|
|
73
|
+
delay: 0,
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
let roomId = "03159020-59a8-4d10-a801-8aef895141a3";
|
|
@@ -90,7 +91,6 @@
|
|
|
90
91
|
const streamContainerElement = document.getElementById('stream-container');
|
|
91
92
|
const streamElement = document.getElementById('stream');
|
|
92
93
|
const roomIdInputElement = document.getElementById('room-id');
|
|
93
|
-
const producerLinkElement = document.getElementById('producer-link');
|
|
94
94
|
|
|
95
95
|
document.addEventListener("DOMContentLoaded", function() {
|
|
96
96
|
audioControls = new AudioControls();
|
|
@@ -14,6 +14,7 @@ class AudioControls {
|
|
|
14
14
|
gainNode;
|
|
15
15
|
equalizerNodes; // List of nodes
|
|
16
16
|
compressorNode;
|
|
17
|
+
delayNode;
|
|
17
18
|
streamDestination;
|
|
18
19
|
|
|
19
20
|
gainDefaultParameters = {
|
|
@@ -35,15 +36,22 @@ class AudioControls {
|
|
|
35
36
|
attack: 0.001, // from 0 to 1 0 - no time required to reduce the gain by 10 dB
|
|
36
37
|
release: 0.15, // from 0 to 1 0 - no time required to increase the gain by 10 dB
|
|
37
38
|
};
|
|
39
|
+
delayDefaultParameters = {
|
|
40
|
+
delay: 0
|
|
41
|
+
};
|
|
38
42
|
|
|
39
43
|
constructor() {
|
|
40
44
|
this.audioContext = new ac();
|
|
41
45
|
|
|
42
46
|
this.streamDestination = this.audioContext.createMediaStreamDestination();
|
|
43
47
|
|
|
48
|
+
this.delayNode = this.audioContext.createDelay(179);
|
|
49
|
+
this.setDelay(this.delayDefaultParameters.delay);
|
|
50
|
+
this.delayNode.connect(this.streamDestination);
|
|
51
|
+
|
|
44
52
|
this.compressorNode = this.audioContext.createDynamicsCompressor();
|
|
45
53
|
this.setCompressorParameters(this.compressorDefaultParameters);
|
|
46
|
-
this.compressorNode.connect(this.
|
|
54
|
+
this.compressorNode.connect(this.delayNode);
|
|
47
55
|
|
|
48
56
|
this.equalizerNodes = this.equalizerDefaultParameters.map( parameters => {
|
|
49
57
|
const biquadFilter = this.audioContext.createBiquadFilter();
|
|
@@ -62,9 +70,8 @@ class AudioControls {
|
|
|
62
70
|
}
|
|
63
71
|
});
|
|
64
72
|
|
|
65
|
-
this.gainParameters = {...this.gainDefaultParameters};
|
|
66
73
|
this.gainNode = this.audioContext.createGain();
|
|
67
|
-
this.setGain(this.
|
|
74
|
+
this.setGain(this.gainDefaultParameters.gain);
|
|
68
75
|
this.gainNode.connect(this.equalizerNodes[0]);
|
|
69
76
|
|
|
70
77
|
this.streamSource = null;
|
|
@@ -188,17 +195,23 @@ class AudioControls {
|
|
|
188
195
|
});
|
|
189
196
|
}
|
|
190
197
|
|
|
198
|
+
setDelay(delay) {
|
|
199
|
+
this.delayNode.delayTime.setValueAtTime(delay, Math.floor(this.audioContext.currentTime));
|
|
200
|
+
}
|
|
201
|
+
|
|
191
202
|
setParametersFromAudioControlsObject(audioControlsObject) {
|
|
192
203
|
if (audioControlsObject.enabled) {
|
|
193
204
|
this.setGain(audioControlsObject.gain.value);
|
|
194
205
|
Object.keys(audioControlsObject.equalizer)
|
|
195
206
|
.forEach(type => this.setEqualizerParameters(audioControlsObject.equalizer[type], type));
|
|
196
207
|
this.setCompressorParameters(audioControlsObject.compressor);
|
|
208
|
+
this.setDelay(audioControlsObject.delay);
|
|
197
209
|
} else {
|
|
198
|
-
this.setGain(this.
|
|
210
|
+
this.setGain(this.gainDefaultParameters.gain);
|
|
199
211
|
this.equalizerDefaultParameters
|
|
200
212
|
.forEach( p => this.setEqualizerParameters(p));
|
|
201
213
|
this.setCompressorParameters(this.compressorDefaultParameters);
|
|
214
|
+
this.setDelay(0);
|
|
202
215
|
}
|
|
203
216
|
}
|
|
204
217
|
|
package/example/index.html
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
<button onclick="unpublish()">unpublish</button>
|
|
18
18
|
<button onclick="toggleVideo()">toggle video</button>
|
|
19
19
|
<button onclick="toggleAudio()">toggle audio</button>
|
|
20
|
-
<button onclick="setRoom()">gulugulu</button>
|
|
21
20
|
</div>
|
|
22
21
|
|
|
23
22
|
</div>
|
|
@@ -71,47 +70,35 @@
|
|
|
71
70
|
|
|
72
71
|
|
|
73
72
|
function disconnectRoom() {
|
|
74
|
-
Instance.room.getSessionByConstructId(constructId)
|
|
75
|
-
.then(session => session.disconnect());
|
|
73
|
+
Instance.room.getSessionByConstructId(constructId).disconnect()
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
function startRoom() {
|
|
79
|
-
Instance.room.getSessionByConstructId(constructId)
|
|
80
|
-
|
|
81
|
-
.then(() => Instance.
|
|
82
|
-
.then(
|
|
77
|
+
let sess = Instance.room.getSessionByConstructId(constructId);
|
|
78
|
+
sess.connect()
|
|
79
|
+
.then(() => Instance.utils.getUserStream({hasVideo:true}))
|
|
80
|
+
.then((stream) => sess.publishLocal(stream))
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
function unpublish() {
|
|
86
|
-
Instance.room.getSessionByConstructId(constructId)
|
|
87
|
-
.then(session => session.unpublishLocal());
|
|
84
|
+
Instance.room.getSessionByConstructId(constructId).unpublishLocal()
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
function publish() {
|
|
91
|
-
Instance.room.getSessionByConstructId(constructId)
|
|
92
|
-
.then(session => session.publishLocal(null, {unpublishFirst:true}));
|
|
88
|
+
Instance.room.getSessionByConstructId(constructId).publishLocal(null, {unpublishFirst:true})
|
|
93
89
|
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
function toggleVideo() {
|
|
97
|
-
Instance.room.getSessionByConstructId(constructId)
|
|
98
|
-
.then(session => session.toggleVideo());
|
|
93
|
+
Instance.room.getSessionByConstructId(constructId).toggleVideo()
|
|
99
94
|
}
|
|
100
95
|
|
|
101
96
|
function toggleAudio() {
|
|
102
|
-
Instance.room.getSessionByConstructId(constructId)
|
|
103
|
-
.then(session => session.toggleAudio());
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function setRoom() {
|
|
107
|
-
Instance.room.updateRoom({roomId, isPublic: false})
|
|
97
|
+
Instance.room.getSessionByConstructId(constructId).toggleAudio()
|
|
108
98
|
}
|
|
109
99
|
|
|
110
100
|
let Instance = WatchTogetherSDK({debug:true})({instanceType:'reactooDemo'});
|
|
111
101
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
102
|
Instance.auth.$on('login', () => {
|
|
116
103
|
console.log('We are in');
|
|
117
104
|
});
|
|
@@ -160,7 +147,9 @@
|
|
|
160
147
|
})
|
|
161
148
|
|
|
162
149
|
})
|
|
163
|
-
.then(r => Instance.room.createSession({constructId, roomId:r.roomId, pinHash: r.pinHash
|
|
150
|
+
.then(r => Instance.room.createSession({constructId, roomId:r.roomId, pinHash: r.pinHash, options: {
|
|
151
|
+
//subscriptionRules: {participant: {videoWall: [], watchTogether: []}}
|
|
152
|
+
}})) // pin hash is not needed if you're owner of the room
|
|
164
153
|
.then(session => {
|
|
165
154
|
|
|
166
155
|
session.$on('connecting', (status) => {
|
package/package.json
CHANGED
|
@@ -35,7 +35,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
35
35
|
|
|
36
36
|
room.on('addLocalParticipant', () => {
|
|
37
37
|
|
|
38
|
-
// TODO: this doesnt seem to be fixable until we switch to
|
|
38
|
+
// TODO: this doesnt seem to be fixable until we switch to different type of messaging
|
|
39
39
|
// At some random case we don't get message back if we don't wait
|
|
40
40
|
|
|
41
41
|
clearTimeout(alpTimeoutId);
|
|
@@ -189,10 +189,10 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
189
189
|
}
|
|
190
190
|
},
|
|
191
191
|
|
|
192
|
-
renderPlayer: function (playerWrapper, fullscreenElement) {
|
|
192
|
+
renderPlayer: function (playerWrapper, fullscreenElement, roomId) {
|
|
193
193
|
try {
|
|
194
194
|
this.syncModule = syncUniversal({room, wt, roomSession: this, emitter});
|
|
195
|
-
this.playerInterface = wt.__privates.playerFactory(playerWrapper, fullscreenElement, this.syncModule.getHandlers(), {roomId
|
|
195
|
+
this.playerInterface = wt.__privates.playerFactory(playerWrapper, fullscreenElement, this.syncModule.getHandlers(), {roomId});
|
|
196
196
|
this.syncModule.initialize({playerInterface: this.playerInterface});
|
|
197
197
|
return true;
|
|
198
198
|
} catch (e) {
|