Skip to content

Commit 23a6440

Browse files
Merge pull request #209007 from DaybreakQuip/patch-4
Update video-calling-windows.md
2 parents d809582 + b43e8e3 commit 23a6440

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

articles/communication-services/quickstarts/voice-video-calling/includes/video-calling/video-calling-windows.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,22 @@ private async void Agent_OnIncomingCall(object sender, IncomingCall incomingcall
257257
All remote participants are available through the `RemoteParticipants` collection on a call instance. Once the call is connected we can access the remote participants of the call and handle the remote video streams.
258258

259259
```C#
260+
private async void Call_OnVideoStreamsUpdated(object sender, RemoteVideoStreamsEventArgs args)
261+
{
262+
foreach (var remoteVideoStream in args.AddedRemoteVideoStreams)
263+
{
264+
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
265+
{
266+
RemoteVideo.Source = await remoteVideoStream.Start();
267+
});
268+
}
269+
270+
foreach (var remoteVideoStream in args.RemovedRemoteVideoStreams)
271+
{
272+
remoteVideoStream.Stop();
273+
}
274+
}
275+
260276
private async void Agent_OnCallsUpdated(object sender, CallsUpdatedEventArgs args)
261277
{
262278
foreach (var call in args.AddedCalls)
@@ -266,7 +282,7 @@ private async void Agent_OnCallsUpdated(object sender, CallsUpdatedEventArgs arg
266282
String remoteParticipantMRI = remoteParticipant.Identifier.ToString();
267283
remoteParticipantDictionary.TryAdd(remoteParticipantMRI, remoteParticipant);
268284
await AddVideoStreams(remoteParticipant.VideoStreams);
269-
remoteParticipant.OnVideoStreamsUpdated += async (s, a) => await AddVideoStreams(a.AddedRemoteVideoStreams);
285+
remoteParticipant.OnVideoStreamsUpdated += Call_OnVideoStreamsUpdated;
270286
}
271287
}
272288
}
@@ -278,7 +294,13 @@ private async void Call_OnRemoteParticipantsUpdated(object sender, ParticipantsU
278294
String remoteParticipantMRI = remoteParticipant.Identifier.ToString();
279295
remoteParticipantDictionary.TryAdd(remoteParticipantMRI, remoteParticipant);
280296
await AddVideoStreams(remoteParticipant.VideoStreams);
281-
remoteParticipant.OnVideoStreamsUpdated += async (s, a) => await AddVideoStreams(a.AddedRemoteVideoStreams);
297+
remoteParticipant.OnVideoStreamsUpdated += Call_OnVideoStreamsUpdated;
298+
}
299+
300+
foreach (var remoteParticipant in args.RemovedParticipants)
301+
{
302+
String remoteParticipantMRI = remoteParticipant.Identifier.ToString();
303+
remoteParticipantDictionary.Remove(remoteParticipantMRI);
282304
}
283305
}
284306
```
@@ -305,7 +327,7 @@ private async Task AddVideoStreams(IReadOnlyList<RemoteVideoStream> streams)
305327
```
306328

307329
## Call state update
308-
We need to clean the video renderers once the call is disconnected.
330+
We need to clean the video renderers once the call is disconnected and handle the case when the remote participants initially join the call.
309331

310332
```C#
311333
private async void Call_OnStateChanged(object sender, PropertyChangedEventArgs args)
@@ -319,8 +341,18 @@ private async void Call_OnStateChanged(object sender, PropertyChangedEventArgs a
319341
RemoteVideo.Source = null;
320342
});
321343
break;
344+
345+
case CallState.Connected:
346+
foreach (var remoteParticipant in call.RemoteParticipants)
347+
{
348+
String remoteParticipantMRI = remoteParticipant.Identifier.ToString();
349+
remoteParticipantDictionary.TryAdd(remoteParticipantMRI, remoteParticipant);
350+
await AddVideoStreams(remoteParticipant.VideoStreams);
351+
remoteParticipant.OnVideoStreamsUpdated += Call_OnVideoStreamsUpdated;
352+
}
353+
break;
354+
322355
default:
323-
Debug.WriteLine(((Call)sender).State);
324356
break;
325357
}
326358
}

0 commit comments

Comments
 (0)