videocall-client-socket 0.1.4 → 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 +25 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,13 +12,16 @@ A simple WebRTC client library for peer-to-peer video calls using [simple-peer](
|
|
|
12
12
|
npm install videocall-client-socket
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
⚠️IMPORTANT!!!⚠️
|
|
16
|
+
This package expects simple-peer to be loaded via CDN in your HTML.
|
|
17
|
+
✅ Add this in your head:
|
|
18
|
+
|
|
15
19
|
```bash
|
|
16
|
-
This package expects simple-peer to be loaded via CDN in your HTML if you're not bundling it directly.
|
|
17
|
-
✅ Add this in your <head>:
|
|
18
20
|
<script src="https://cdn.jsdelivr.net/npm/simple-peer/simplepeer.min.js"></script>
|
|
19
|
-
This makes SimplePeer available globally in the browser.
|
|
20
21
|
```
|
|
21
22
|
|
|
23
|
+
This makes SimplePeer available globally in the browser.
|
|
24
|
+
|
|
22
25
|
---
|
|
23
26
|
|
|
24
27
|
## 🚀 Quick Start
|
|
@@ -28,11 +31,26 @@ import * as VideoClient from "videocall-client-socket";
|
|
|
28
31
|
import { v4 as uuidv4 } from "uuid";
|
|
29
32
|
|
|
30
33
|
const userId = uuidv4();
|
|
31
|
-
const
|
|
34
|
+
const channelName = "roomABC";
|
|
32
35
|
|
|
33
36
|
// Step 1: Subscribe to events before anything else
|
|
34
|
-
VideoClient.on("user-published",
|
|
35
|
-
|
|
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
|
+
});
|
|
36
54
|
VideoClient.on("user-media-toggled", (data) => {
|
|
37
55
|
console.log(data.user.uuid, data.type, data.enabled);
|
|
38
56
|
});
|
|
@@ -45,7 +63,7 @@ VideoClient.playVideoTrack("localVideo");
|
|
|
45
63
|
|
|
46
64
|
// Step 4: Join the signaling channel
|
|
47
65
|
VideoClient.setServerURL("http://localhost:3000");
|
|
48
|
-
VideoClient.joinChannel(userId,
|
|
66
|
+
VideoClient.joinChannel(userId, channelName);
|
|
49
67
|
```
|
|
50
68
|
|
|
51
69
|
---
|