videocall-client-socket 0.1.5 → 0.1.6
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/README.md +20 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npm install videocall-client-socket
|
|
|
14
14
|
|
|
15
15
|
⚠️IMPORTANT!!!⚠️
|
|
16
16
|
This package expects simple-peer to be loaded via CDN in your HTML.
|
|
17
|
-
✅ Add this in your
|
|
17
|
+
✅ Add this in your head:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
<script src="https://cdn.jsdelivr.net/npm/simple-peer/simplepeer.min.js"></script>
|
|
@@ -31,11 +31,26 @@ import * as VideoClient from "videocall-client-socket";
|
|
|
31
31
|
import { v4 as uuidv4 } from "uuid";
|
|
32
32
|
|
|
33
33
|
const userId = uuidv4();
|
|
34
|
-
const
|
|
34
|
+
const channelName = "roomABC";
|
|
35
35
|
|
|
36
36
|
// Step 1: Subscribe to events before anything else
|
|
37
|
-
VideoClient.on("user-published",
|
|
38
|
-
|
|
37
|
+
VideoClient.on("user-published", (data) => {
|
|
38
|
+
const { user, mediaType } = data;
|
|
39
|
+
const video = document.createElement("video");
|
|
40
|
+
video.srcObject = user.videotrack;
|
|
41
|
+
video.autoplay = true;
|
|
42
|
+
video.id = user.uuid;
|
|
43
|
+
document.body.appendChild(video);
|
|
44
|
+
});
|
|
45
|
+
VideoClient.on("user-unpublished", (data) => {
|
|
46
|
+
const { user, mediaType } = data;
|
|
47
|
+
if (mediaType === "video") {
|
|
48
|
+
const video = document.getElementById(`${user.uuid}`);
|
|
49
|
+
if (video) {
|
|
50
|
+
video.remove();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
39
54
|
VideoClient.on("user-media-toggled", (data) => {
|
|
40
55
|
console.log(data.user.uuid, data.type, data.enabled);
|
|
41
56
|
});
|
|
@@ -48,7 +63,7 @@ VideoClient.playVideoTrack("localVideo");
|
|
|
48
63
|
|
|
49
64
|
// Step 4: Join the signaling channel
|
|
50
65
|
VideoClient.setServerURL("http://localhost:3000");
|
|
51
|
-
VideoClient.joinChannel(userId,
|
|
66
|
+
VideoClient.joinChannel(userId, channelName);
|
|
52
67
|
```
|
|
53
68
|
|
|
54
69
|
---
|