@whereby.com/browser-sdk 2.0.0-alpha1 → 2.0.0-alpha11

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 CHANGED
@@ -6,11 +6,13 @@ Whereby browser SDK is a library for seamless integration of Whereby (https://wh
6
6
 
7
7
  ## Installation
8
8
 
9
- ```
9
+ ```shell
10
10
  npm install @whereby.com/browser-sdk
11
11
  ```
12
+
12
13
  or
13
- ```
14
+
15
+ ```shell
14
16
  yarn add @whereby.com/browser-sdk
15
17
  ```
16
18
 
@@ -20,19 +22,57 @@ yarn add @whereby.com/browser-sdk
20
22
 
21
23
  ### React hooks
22
24
 
23
- The `useRoomConnection` hook provides a way to connect participants in a given room, subscribe to state updates, and perform actions on the connection, like toggling camera or microphone.
25
+ #### useLocalMedia
26
+
27
+ The `useLocalMedia` hook enables preview and selection of local devices (camera & microphone) prior to establishing a connection within a Whereby room. Use this hook to build rich pre-call
28
+ experiences, allowing end users to confirm their device selection up-front. This hook works seamlessly with the `useRoomConnection` hook described below.
29
+
30
+ ```js
31
+ import { useLocalMedia, VideoView } from “@whereby.com/browser-sdk”;
32
+
33
+ function MyPreCallUX() {
34
+ const localMedia = useLocalMedia({ audio: false, video: true });
35
+
36
+ const { currentCameraDeviceId, cameraDevices, localStream } = localMedia.state;
37
+ const { setCameraDevice, toggleCameraEnabled } = localMedia.actions;
38
+ const { VideoView } = components;
39
+
40
+ return <div className="preCallView">
41
+ { /* Render any UI, making use of state */ }
42
+ { cameraDevices.map((d) => (
43
+ <p
44
+ key={d.deviceId}
45
+ onClick={() => {
46
+ if (d.deviceId !== currentCameraDeviceId) {
47
+ setCameraDevice(d.deviceId);
48
+ }
49
+ }}
50
+ >
51
+ {d.label}
52
+ </p>
53
+ )) }
54
+ <VideoView muted stream={localStream} />
55
+ </div>;
56
+ }
24
57
 
25
58
  ```
59
+
60
+ #### useRoomConnection
61
+
62
+ The `useRoomConnection` hook provides a way to connect participants in a given room, subscribe to state updates, and perform actions on the connection, like toggling camera or microphone.
63
+
64
+ ```js
26
65
  import { useRoomConnection } from “@whereby.com/browser-sdk”;
27
66
 
28
67
  function MyCallUX( { roomUrl, localStream }) {
29
- const [state, actions, components ] = useRoomConnection(
68
+ const { state, actions, components } = useRoomConnection(
30
69
  "<room_url>"
31
70
  {
32
- localMediaConstraints: {
71
+ localMedia: null, // Supply localMedia from `useLocalMedia` hook, or constraints
72
+ localMediaConstraints: {
33
73
  audio: true,
34
74
  video: true,
35
- },
75
+ }
36
76
  }
37
77
  );
38
78
 
@@ -54,23 +94,21 @@ function MyCallUX( { roomUrl, localStream }) {
54
94
 
55
95
  Use the `<whereby-embed />` web component to make use of Whereby's pre-built responsive UI. Refer to our [documentation](https://docs.whereby.com/embedding-rooms/in-a-web-page/using-the-whereby-embed-element) to learn which attributes are supported.
56
96
 
57
-
58
97
  #### React
59
98
 
60
- ```
61
- import "@whereby.com/browser-sdk"
99
+ ```js
100
+ import "@whereby.com/browser-sdk";
62
101
 
63
102
  const MyComponent = ({ roomUrl }) => {
64
- return <whereby-embed chat="off" room={roomUrl} />
65
- }
66
-
67
- export default MyComponent
103
+ return <whereby-embed chat="off" room={roomUrl} />;
104
+ };
68
105
 
106
+ export default MyComponent;
69
107
  ```
70
108
 
71
109
  #### In plain HTML
72
110
 
73
- ```
111
+ ```html
74
112
  <html>
75
113
  <head>
76
114
  <script src="...."></script>