@whereby.com/browser-sdk 2.0.0-alpha5 → 2.0.0-alpha7

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
@@ -20,6 +20,42 @@ yarn add @whereby.com/browser-sdk
20
20
 
21
21
  ### React hooks
22
22
 
23
+ #### useLocalMedia
24
+ 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
25
+ experiences, allowing end users to confirm their device selection up-front. This hook works seamlessly with the `useRoomConnection` hook described below.
26
+
27
+ ```
28
+ import { useLocalMedia, VideoView } from “@whereby.com/browser-sdk”;
29
+
30
+ function MyPreCallUX() {
31
+ const localMedia = useLocalMedia({ audio: false, video: true });
32
+
33
+ const { currentCameraDeviceId, cameraDevices, localStream } = localMedia.state;
34
+ const { setCameraDevice, toggleCameraEnabled } = localMedia.actions;
35
+ const { VideoView } = components;
36
+
37
+ return <div className="preCallView">
38
+ { /* Render any UI, making use of state */ }
39
+ { cameraDevices.map((d) => (
40
+ <p
41
+ key={d.deviceId}
42
+ onClick={() => {
43
+ if (d.deviceId !== currentCameraDeviceId) {
44
+ setCameraDevice(d.deviceId);
45
+ }
46
+ }}
47
+ >
48
+ {d.label}
49
+ </p>
50
+ )) }
51
+ <VideoView muted stream={localStream} />
52
+ </div>;
53
+ }
54
+
55
+ ```
56
+
57
+
58
+ #### useRoomConnection
23
59
  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.
24
60
 
25
61
  ```
@@ -29,10 +65,11 @@ function MyCallUX( { roomUrl, localStream }) {
29
65
  const [state, actions, components ] = useRoomConnection(
30
66
  "<room_url>"
31
67
  {
32
- localMediaConstraints: {
68
+ localMedia: null, // Supply localMedia from `useLocalMedia` hook, or constraints below
69
+ localMediaConstraints: {
33
70
  audio: true,
34
71
  video: true,
35
- },
72
+ }
36
73
  }
37
74
  );
38
75