@reactoo/watchtogether-sdk-js 2.7.51 → 2.7.52-beta.2
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 +94 -737
- package/dist/watchtogether-sdk.js.map +1 -1
- package/dist/watchtogether-sdk.min.js +2 -3
- package/example/index.html +83 -17
- package/package.json +9 -2
- package/webpack.config.js +8 -4
package/example/index.html
CHANGED
|
@@ -5,31 +5,31 @@
|
|
|
5
5
|
<meta charset="utf-8">
|
|
6
6
|
<title>The Example</title>
|
|
7
7
|
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
|
8
|
-
<script src="../dist/watchtogether-sdk.min.js"></script>
|
|
9
8
|
</head>
|
|
10
9
|
<body>
|
|
11
10
|
<div class="content">
|
|
12
11
|
<video id="thevideo" class="contentVideo" autoplay playsinline controls style="width: 400px" muted="muted" src="https://assetcdn.reactoo.com/watfordFc/Norwich_2010_B_roll_2min16_mute.mp4"></video>
|
|
13
12
|
<div>
|
|
14
|
-
<button onclick="startRoom()">Connect and publish</button>
|
|
15
|
-
<button onclick="startRoom2()">Connect and publish with screen share</button>
|
|
16
|
-
<button onclick="startRoom3()">Connect and publish with blank screen</button>
|
|
17
|
-
<button onclick="disconnectRoom()">Disconnect</button>
|
|
18
|
-
<button onclick="publish()">publish cam</button>
|
|
19
|
-
<button onclick="publishBlankCam()">publish blank cam</button>
|
|
20
|
-
<button onclick="publishBlank()">publish blank screen</button>
|
|
21
|
-
<button onclick="publishScreen()">publish screen</button>
|
|
22
|
-
<button onclick="unpublish()">unpublish</button>
|
|
23
|
-
<button onclick="toggleVideo()">toggle video</button>
|
|
24
|
-
<button onclick="toggleAudio()">toggle audio</button>
|
|
25
|
-
<button onclick="hento()">get client</button>
|
|
13
|
+
<button onclick="window.startRoom()">Connect and publish</button>
|
|
14
|
+
<button onclick="window.startRoom2()">Connect and publish with screen share</button>
|
|
15
|
+
<button onclick="window.startRoom3()">Connect and publish with blank screen</button>
|
|
16
|
+
<button onclick="window.disconnectRoom()">Disconnect</button>
|
|
17
|
+
<button onclick="window.publish()">publish cam</button>
|
|
18
|
+
<button onclick="window.publishBlankCam()">publish blank cam</button>
|
|
19
|
+
<button onclick="window.publishBlank()">publish blank screen</button>
|
|
20
|
+
<button onclick="window.publishScreen()">publish screen</button>
|
|
21
|
+
<button onclick="window.unpublish()">unpublish</button>
|
|
22
|
+
<button onclick="window.toggleVideo()">toggle video</button>
|
|
23
|
+
<button onclick="window.toggleAudio()">toggle audio</button>
|
|
24
|
+
<button onclick="window.hento()">get client</button>
|
|
26
25
|
</div>
|
|
27
26
|
|
|
28
27
|
</div>
|
|
29
28
|
<div class="participants"></div>
|
|
30
29
|
|
|
31
|
-
<script>
|
|
32
|
-
|
|
30
|
+
<script type="module">
|
|
31
|
+
import WatchTogetherSDK from '../dist/watchtogether-sdk.js';
|
|
32
|
+
|
|
33
33
|
//https://studio.reactoo.com/room/edf441b3-7415-49c4-9557-273cb93bc746/LJj4W2Cz-nG3U-lb0R-TAaY-o7Thmb8xHSbE
|
|
34
34
|
|
|
35
35
|
let roomId = "d841ad58-e5a6-4cb8-aeb8-c92499a213a4"; // It will create room automatically if not set
|
|
@@ -105,7 +105,6 @@
|
|
|
105
105
|
els.length && els.forEach(el => el.parentNode.removeChild(el));
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
109
108
|
function disconnectRoom() {
|
|
110
109
|
Instance.room.getSessionByConstructId(constructId).disconnect()
|
|
111
110
|
}
|
|
@@ -451,8 +450,75 @@
|
|
|
451
450
|
|
|
452
451
|
});
|
|
453
452
|
|
|
453
|
+
// Make functions globally accessible
|
|
454
|
+
window.startRoom = function() {
|
|
455
|
+
let sess = Instance.room.getSessionByConstructId(constructId);
|
|
456
|
+
sess.connect()
|
|
457
|
+
.then(() => Instance.utils.getUserStream({hasVideo:true, hasAudio: true, isHd: true}))
|
|
458
|
+
.then((stream) => sess.publishLocal(stream))
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
window.disconnectRoom = function() {
|
|
462
|
+
Instance.room.getSessionByConstructId(constructId).disconnect()
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
window.publish = function(vDeviceId) {
|
|
466
|
+
let sess = Instance.room.getSessionByConstructId(constructId);
|
|
467
|
+
Instance.utils.getUserStream({hasVideo:true, vDeviceId})
|
|
468
|
+
.then(stream => sess.publishLocal(stream))
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
window.publishBlankCam = function() {
|
|
472
|
+
let sess = Instance.room.getSessionByConstructId(constructId);
|
|
473
|
+
sess.publishLocal(null, 'camera0')
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
window.publishBlank = function() {
|
|
477
|
+
let sess = Instance.room.getSessionByConstructId(constructId);
|
|
478
|
+
sess.publishLocal(null, 'screen')
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
window.publishScreen = function(vDeviceId) {
|
|
482
|
+
let sess = Instance.room.getSessionByConstructId(constructId);
|
|
483
|
+
Instance.utils.getDisplayMedia()
|
|
484
|
+
.then((stream) => sess.publishLocal(stream, 'screen'))
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
window.unpublish = function() {
|
|
488
|
+
Instance.room.getSessionByConstructId(constructId).unpublishLocal()
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
window.toggleVideo = function() {
|
|
492
|
+
Instance.room.getSessionByConstructId(constructId).toggleVideo()
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
window.toggleAudio = function() {
|
|
496
|
+
Instance.room.getSessionByConstructId(constructId).toggleAudio()
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
window.hento = function() {
|
|
500
|
+
//Instance.system.getSettings();
|
|
501
|
+
Instance.system.getClient()
|
|
502
|
+
.then(r => {
|
|
503
|
+
console.log(r)
|
|
504
|
+
})
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
window.startRoom2 = function() {
|
|
508
|
+
let sess = Instance.room.getSessionByConstructId(constructId);
|
|
509
|
+
sess.connect()
|
|
510
|
+
.then(() => Instance.utils.getUserStream({hasVideo:true}))
|
|
511
|
+
.then((stream) => sess.publishLocal(stream))
|
|
512
|
+
.then(() => Instance.utils.getDisplayMedia())
|
|
513
|
+
.then((stream) => sess.publishLocal(stream, 'screen'))
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
window.startRoom3 = function() {
|
|
517
|
+
let sess = Instance.room.getSessionByConstructId(constructId);
|
|
518
|
+
sess.connect().then(() => sess.publishLocal(null, 'camera0'))
|
|
519
|
+
}
|
|
454
520
|
|
|
455
521
|
</script>
|
|
456
522
|
|
|
457
523
|
</body>
|
|
458
|
-
</html>
|
|
524
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactoo/watchtogether-sdk-js",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.52-beta.2",
|
|
4
4
|
"description": "Javascript SDK for Reactoo",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/watchtogether-sdk.js",
|
|
6
|
+
"module": "dist/watchtogether-sdk.js",
|
|
6
7
|
"unpkg": "dist/watchtogether-sdk.min.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/watchtogether-sdk.js",
|
|
11
|
+
"require": "./dist/watchtogether-sdk.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
"scripts": {
|
|
8
15
|
"build": "webpack --mode=production",
|
|
9
16
|
"dev": "webpack --mode=development --watch"
|
package/webpack.config.js
CHANGED
|
@@ -18,13 +18,17 @@ module.exports = (env, argv) => {
|
|
|
18
18
|
output: {
|
|
19
19
|
path: path.resolve(__dirname, 'dist'),
|
|
20
20
|
filename: outputFile,
|
|
21
|
-
library:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
library: {
|
|
22
|
+
type: 'module'
|
|
23
|
+
},
|
|
24
|
+
module: true,
|
|
25
|
+
environment: { module: true },
|
|
25
26
|
globalObject: "typeof self !== 'undefined' ? self : this",
|
|
26
27
|
publicPath: '',
|
|
27
28
|
},
|
|
29
|
+
experiments: {
|
|
30
|
+
outputModule: true,
|
|
31
|
+
},
|
|
28
32
|
module: {
|
|
29
33
|
rules: [
|
|
30
34
|
{
|