Skip to content

Commit b061a08

Browse files
Merge pull request #242190 from chriswhilar/patch-66
Update video-management docs for screen sharing
2 parents bb41493 + 9c1cef1 commit b061a08

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

articles/communication-services/how-tos/calling-sdk/includes/manage-video/manage-video-web.md

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,17 @@ await deviceManager.selectSpeaker(localSpeakers[0]);
5656
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.
5757

5858
```js
59+
// To start viewing local camera preview
5960
const cameras = await deviceManager.getCameras();
6061
const camera = cameras[0];
6162
const localVideoStream = new LocalVideoStream(camera);
6263
const videoStreamRenderer = new VideoStreamRenderer(localVideoStream);
6364
const view = await videoStreamRenderer.createView();
6465
htmlElement.appendChild(view.target);
66+
67+
// To stop viewing local camera preview
68+
view.dispose();
69+
htmlElement.removeChild(view.target);
6570
```
6671

6772
### Request permission to camera and microphone
@@ -120,15 +125,13 @@ await call.startVideo(localVideoStream);
120125
After you successfully start sending video, a `LocalVideoStream` instance is added to the `localVideoStreams` collection on a call instance.
121126

122127
```js
123-
call.localVideoStreams[0] === localVideoStream;
128+
const localVideoStream = call.localVideoStreams.find( (stream) => { return stream.mediaStreamType === 'Video'} );
124129
```
125130

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:
127132

128133
```js
129134
await call.stopVideo(localVideoStream);
130-
// or
131-
await call.stopVideo(call.localVideoStreams[0]);
132135
```
133136

134137
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', () => {
193196
});
194197
```
195198

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
197229

198230
To list the video streams and screen sharing streams of remote participants, inspect the `videoStreams` collections:
199231

0 commit comments

Comments
 (0)