In a previous blog post, we discussed the advent of Microsoft’s new Communication-Platform-as-a-Service (CPaaS) platform, Azure Communication Services. Today, we will get our hands dirty and implement a Group Video Calling App that can handle up to 50 participants. We will go through setting up the app in your local environment and look at some key features in the code.
Now, clone the repository after navigating into your preferred directory:
Next, open up /Communication/samples/Group Calling Hero Sample/Web/Calling within your Visual Studio instance. Replace ResourceConnectionString with your connection string. You are now ready to build and run our group video calling app.
If you have issues just clean (Build -> Clean All) and rebuild (Build -> Rebuild All) the project.
You should now have the app running at localhost:5001.
Let’s start with the server-side code generation:
Here, we write the behavior for the /userToken route. We will call this from the client side to receive a token that will allow us to join/start the session. We create a random CommunicationUser object and then generate a token for that user. We could also authenticate a specific user using O-auth with this class. That would look a little something like this:
We want anonymous access to our app, so we don’t need this for now.
Let’s look at what we do with this token on the client side:
Here, userToken is what we get from the /userToken API call. We create a CallClient object with this token. We will use this to start the call and register signal handlers associated with the call.
Next, let’s take a look at some of the signal handlers of interest:
This will fire off when a participant mute/unmute themselves or some other state change happens associated with that user.
These two event handlers are used to populate the participant list and also to update the UI to accommodate new participants or to remove old ones.
Finally, let’s take a look at how we join the call:
The object returned by this method is basically the control room for the call. It can be used to mute/unmute audio, start/stop video, get all participants, check which participants are speaking etc.
Similar to how we start the call, this is how we end it:
This concludes the basic configuration and elements you need to set up and group video calling Azure Communication Service app. You can see what I built below. Happy Coding!
Are you interested in building your own custom live video application using Microsoft’s Azure Communication Services or any other CPaaS? Perhaps you have a business workflow in which you’d like to integrate Teams and Azure Communication Services. Our team of WebRTC development experts can build your custom video application for web or mobile. Contact us for more information!