@@ -56,12 +56,17 @@ await deviceManager.selectSpeaker(localSpeakers[0]);
56
56
You can use ` deviceManager ` and ` VideoStreamRenderer ` to begin rendering streams from your local camera. This stream won't be sent to other participants; it's a local preview feed.
57
57
58
58
``` js
59
+ // To start viewing local camera preview
59
60
const cameras = await deviceManager .getCameras ();
60
61
const camera = cameras[0 ];
61
62
const localVideoStream = new LocalVideoStream (camera);
62
63
const videoStreamRenderer = new VideoStreamRenderer (localVideoStream);
63
64
const view = await videoStreamRenderer .createView ();
64
65
htmlElement .appendChild (view .target );
66
+
67
+ // To stop viewing local camera preview
68
+ view .dispose ();
69
+ htmlElement .removeChild (view .target );
65
70
```
66
71
67
72
### Request permission to camera and microphone
@@ -120,15 +125,13 @@ await call.startVideo(localVideoStream);
120
125
After you successfully start sending video, a ` LocalVideoStream ` instance is added to the ` localVideoStreams ` collection on a call instance.
121
126
122
127
``` js
123
- call .localVideoStreams [ 0 ] === localVideoStream ;
128
+ const localVideoStream = call .localVideoStreams . find ( ( stream ) => { return stream . mediaStreamType === ' Video ' } ) ;
124
129
```
125
130
126
- To stop local video while on a call, pass the ` localVideoStream ` instance that's available in the ` localVideoStreams ` collection :
131
+ To stop local video while on a call, pass the ` localVideoStream ` instance that's being used for video :
127
132
128
133
``` js
129
134
await call .stopVideo (localVideoStream);
130
- // or
131
- await call .stopVideo (call .localVideoStreams [0 ]);
132
135
```
133
136
134
137
You can switch to a different camera device while a video is sending by invoking ` switchSource ` on a ` localVideoStream ` instance:
@@ -193,7 +196,36 @@ call.off('isScreenSharingOnChanged', () => {
193
196
});
194
197
```
195
198
196
- ## Render remote participant video streams
199
+ [ !INCLUDE [ Public Preview Disclaimer] ( ../../../../includes/public-preview-include.md )]
200
+ Local screen share preview is in public preview and available as part of version 1.15.1-beta.1+.
201
+ ### Local screen share preview
202
+ You can use ` VideoStreamRenderer ` to begin rendering streams from your local screen share so you can see what you are sending as a screen sharing stream.
203
+ ``` js
204
+ // To start viewing local screen share preview
205
+ await call .startScreenSharing ();
206
+ const localScreenSharingStream = call .localVideoStreams .find ( (stream ) => { return stream .mediaStreamType === ' ScreenSharing' });
207
+ const videoStreamRenderer = new VideoStreamRenderer (localScreenSharingStream);
208
+ const view = await videoStreamRenderer .createView ();
209
+ htmlElement .appendChild (view .target );
210
+
211
+ // To stop viewing local screen share preview.
212
+ await call .stopScreenSharing ();
213
+ view .dispose ();
214
+ htmlElement .removeChild (view .target );
215
+
216
+ // Screen sharing can also be stoped by clicking on the native browser's "Stop sharing" button.
217
+ // The isScreenSharingOnChanged event will be triggered where you can check the value of call.isScreenSharingOn.
218
+ // If the value is false, then that means screen sharing is turned off and so we can go ahead and dispose the screen share preview.
219
+ // This event is also triggered for the case when stopping screen sharing via Call.stopScreenSharing() API.
220
+ call .on (' isScreenSharingOnChanged' , () => {
221
+ if (! call .isScreenSharingOn ) {
222
+ view .dispose ();
223
+ htmlElement .removeChild (view .target );
224
+ }
225
+ });
226
+ ```
227
+
228
+ ## Render remote participant video/screensharing streams
197
229
198
230
To list the video streams and screen sharing streams of remote participants, inspect the ` videoStreams ` collections:
199
231
0 commit comments