Skip to content

Commit 7606a88

Browse files
authored
Merge pull request #267603 from roadieroundup/main
changes in voice calling quick starts for android and windows.
2 parents 5276e3d + 66e88ae commit 7606a88

File tree

6 files changed

+78
-26
lines changed

6 files changed

+78
-26
lines changed

articles/communication-services/quickstarts/voice-video-calling/includes/get-started/get-started-android.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ From Android Studio, select Start a new Android Studio project.
3636

3737
:::image type="content" source="../../media/android/studio-new-project.png" alt-text="Screenshot showing the 'Start a new Android Studio Project' button selected in Android Studio.":::
3838

39-
Select "Empty Activity" project template under "Phone and Tablet".
39+
Select "Empty Views Activity" project template under "Phone and Tablet".
4040

4141
:::image type="content" source="../../media/android/studio-blank-activity.png" alt-text="Screenshot showing the 'Empty Activity' option selected in the Project Template Screen.":::
4242

@@ -48,23 +48,21 @@ Select Minimum SDK of "API 26: Android 8.0 (Oreo)" or greater.
4848
### Install the package
4949

5050
<!-- TODO: update with instructions on how to download, install and add package to project -->
51-
Locate your project level build.gradle and make sure to add `mavenCentral()` to the list of repositories under `buildscript` and `allprojects`
51+
Locate your project `settings.gradle.kts` and make sure to see `mavenCentral()` at the list of repositories under `pluginManagement` and `dependencyResolutionManagement`
5252
```groovy
53-
buildscript {
53+
pluginManagement {
5454
repositories {
5555
...
5656
mavenCentral()
5757
...
5858
}
5959
}
60-
```
6160
62-
```groovy
63-
allprojects {
61+
dependencyResolutionManagement {
62+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
6463
repositories {
6564
...
6665
mavenCentral()
67-
...
6866
}
6967
}
7068
```
@@ -73,9 +71,7 @@ Then, in your module level build.gradle add the following lines to the dependenc
7371
```groovy
7472
android {
7573
...
76-
packagingOptions {
77-
pickFirst 'META-INF/*'
78-
}
74+
7975
compileOptions {
8076
sourceCompatibility JavaVersion.VERSION_1_8
8177
targetCompatibility JavaVersion.VERSION_1_8
@@ -84,7 +80,7 @@ android {
8480
8581
dependencies {
8682
...
87-
implementation 'com.azure.android:azure-communication-calling:1.0.0-beta.8'
83+
implementation ("com.azure.android:azure-communication-calling:2.6.0")
8884
...
8985
}
9086
```
@@ -160,6 +156,7 @@ Two inputs are needed: a text input for the callee ID, and a button for placing
160156
android:ems="10"
161157
android:hint="Callee Id"
162158
android:inputType="textPersonName"
159+
android:minHeight="48dp"
163160
app:layout_constraintBottom_toTopOf="@+id/call_button"
164161
app:layout_constraintEnd_toEndOf="parent"
165162
app:layout_constraintStart_toStartOf="parent"
@@ -195,6 +192,7 @@ import com.azure.android.communication.calling.StartCallOptions;
195192

196193

197194
import java.util.ArrayList;
195+
import java.util.Arrays;
198196

199197
public class MainActivity extends AppCompatActivity {
200198

@@ -248,13 +246,16 @@ For Android 6.0 and higher (API level 23) and `targetSdkVersion` 23 or higher, p
248246
* Request each required permission if the app doesn't already have it.
249247
*/
250248
private void getAllPermissions() {
251-
String[] requiredPermissions = new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE};
249+
String[] requiredPermissions = new String[]{android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAMERA, android.Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE};
250+
252251
ArrayList<String> permissionsToAskFor = new ArrayList<>();
252+
253253
for (String permission : requiredPermissions) {
254254
if (ActivityCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
255255
permissionsToAskFor.add(permission);
256256
}
257257
}
258+
258259
if (!permissionsToAskFor.isEmpty()) {
259260
ActivityCompat.requestPermissions(this, permissionsToAskFor.toArray(new String[0]), 1);
260261
}
@@ -290,8 +291,8 @@ private void createAgent() {
290291
String userToken = "<User_Access_Token>";
291292

292293
try {
293-
CommunicationTokenCredential credential = new CommunicationTokenCredential(userToken);
294-
callAgent = new CallClient().createCallAgent(getApplicationContext(), credential).get();
294+
CommunicationTokenCredential credential = new CommunicationTokenCredential(userToken);
295+
callAgent = new CallClient().createCallAgent(getApplicationContext(), credential).get();
295296
} catch (Exception ex) {
296297
Toast.makeText(getApplicationContext(), "Failed to create call agent.", Toast.LENGTH_SHORT).show();
297298
}
@@ -309,14 +310,15 @@ Placing the call can be done via the call agent, and just requires providing a l
309310
*/
310311
private void startCall() {
311312
EditText calleeIdView = findViewById(R.id.callee_id);
312-
String calleeId = calleeIdView.getText().toString();
313313

314+
String calleeId = calleeIdView.getText().toString();
315+
314316
StartCallOptions options = new StartCallOptions();
315317

316318
callAgent.startCall(
317-
getApplicationContext(),
318-
new CommunicationUserIdentifier[] {new CommunicationUserIdentifier(calleeId)},
319-
options);
319+
getApplicationContext(),
320+
Arrays.asList(new CommunicationUserIdentifier[]{new CommunicationUserIdentifier(calleeId)}),
321+
options);
320322
}
321323
```
322324

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

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ In Visual Studio, create a new project with the **Blank App (Universal Windows)*
3838

3939
#### Install the package
4040

41-
Right select your project and go to `Manage Nuget Packages` to install `Azure.Communication.Calling.WindowsClient` [1.2.0-beta.1](https://www.nuget.org/packages/Azure.Communication.Calling.WindowsClient/1.2.0-beta.1) or superior. Make sure Include Preleased is checked.
41+
Right select your project and go to `Manage Nuget Packages` to install `Azure.Communication.Calling.WindowsClient` [1.4.0](https://www.nuget.org/packages/Azure.Communication.Calling.WindowsClient/1.4.0) or superior. Make sure `Include Prerelease` is checked if you want to see the versions for public preview.
4242

4343
#### Request access
4444

@@ -64,6 +64,9 @@ Open the `MainPage.xaml` of your project and add the `Grid` node to your `Page`:
6464
mc:Ignorable="d"
6565
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Width="800" Height="600">
6666

67+
<!-- Don't forget to replace ‘CallingQuickstart’ with your project’s name -->
68+
69+
6770
<Grid>
6871
<Grid.RowDefinitions>
6972
<RowDefinition Height="16*"/>
@@ -132,7 +135,6 @@ namespace CallingQuickstart
132135
private CommunicationCall call;
133136

134137
private LocalOutgoingAudioStream micStream;
135-
private LocalOutgoingVideoStream cameraStream;
136138

137139
#region Page initialization
138140
public MainPage()
@@ -143,6 +145,8 @@ namespace CallingQuickstart
143145

144146
protected override async void OnNavigatedTo(NavigationEventArgs e)
145147
{
148+
await InitCallAgentAndDeviceManagerAsync();
149+
146150
base.OnNavigatedTo(e);
147151
}
148152
#endregion
@@ -175,6 +179,21 @@ namespace CallingQuickstart
175179
// Handle connected and disconnected state change of a call
176180
}
177181
#endregion
182+
183+
#region Helper methods
184+
185+
private async Task InitCallAgentAndDeviceManagerAsync()
186+
{
187+
//Initialize the call agent and search for devices
188+
}
189+
190+
191+
private async Task<CommunicationCall> StartCallAsync(string acsCallee)
192+
{
193+
// Start a call to an Azure Communication Services user using the CallAgent and the callee id
194+
}
195+
196+
#endregion
178197
}
179198
}
180199
```
@@ -204,16 +223,21 @@ Add `InitCallAgentAndDeviceManagerAsync` function, which bootstraps the SDK. Thi
204223
{
205224
this.callClient = new CallClient(new CallClientOptions() {
206225
Diagnostics = new CallDiagnosticsOptions() {
226+
227+
// make sure to put your project AppName
207228
AppName = "CallingQuickstart",
229+
208230
AppVersion="1.0",
231+
209232
Tags = new[] { "Calling", "ACS", "Windows" }
210233
}
234+
211235
});
212236

213-
// Set up local video stream using the first camera enumerated
237+
// Set up local audio stream using the first mic enumerated
214238
var deviceManager = await this.callClient.GetDeviceManagerAsync();
215-
var camera = deviceManager?.Cameras?.FirstOrDefault();
216239
var mic = deviceManager?.Microphones?.FirstOrDefault();
240+
217241
micStream = new LocalOutgoingAudioStream();
218242

219243
var tokenCredential = new CallTokenCredential(authToken, callTokenRefreshOptions);
@@ -224,6 +248,7 @@ Add `InitCallAgentAndDeviceManagerAsync` function, which bootstraps the SDK. Thi
224248
};
225249

226250
this.callAgent = await this.callClient.CreateCallAgentAsync(tokenCredential, callAgentOptions);
251+
227252
this.callAgent.IncomingCallReceived += OnIncomingCallAsync;
228253
}
229254
```
@@ -233,7 +258,7 @@ Add `InitCallAgentAndDeviceManagerAsync` function, which bootstraps the SDK. Thi
233258
Once a `StartCallOptions` object is obtained, `CallAgent` can be used to initiate the Azure Communication Services call:
234259

235260
```C#
236-
private async Task<CommunicationCall> StartAcsCallAsync(string acsCallee)
261+
private async Task<CommunicationCall> StartCallAsync(string acsCallee)
237262
{
238263
var options = new StartCallOptions();
239264
var call = await this.callAgent.StartCallAsync( new [] { new UserCallIdentifier(acsCallee) }, options);
@@ -268,6 +293,7 @@ Mute the outgoing audio when the `Mute` button is clicked. Add the implementatio
268293
if (muteCheckbox != null)
269294
{
270295
var call = this.callAgent?.Calls?.FirstOrDefault();
296+
271297
if (call != null)
272298
{
273299
if ((bool)muteCheckbox.IsChecked)
@@ -343,9 +369,33 @@ Application has an opportunity to configure how the incoming call should be acce
343369
}
344370
```
345371

372+
### Make call button work
373+
374+
Once the `Callee ID` isn't null or empty, you can start a call.
375+
376+
The call state must be changed using the `OnStateChangedAsync` action.
377+
378+
```C#
379+
380+
private async void CallButton_Click(object sender, RoutedEventArgs e)
381+
{
382+
var callString = CalleeTextBox.Text.Trim();
383+
384+
if (!string.IsNullOrEmpty(callString))
385+
{
386+
call = await StartCallAsync(callString);
387+
388+
call.StateChanged += OnStateChangedAsync;
389+
}
390+
391+
392+
}
393+
394+
```
395+
346396
### Run the code
347397

348-
You can build and run the code on Visual Studio. For solution platforms, we support `ARM64`, `x64` and `x86`.
398+
You can build and run the code on Visual Studio. For solution platforms, we support `ARM64`, `x64`, and `x86`.
349399

350400
You can make an outbound call by providing a user ID in the text field and clicking the `Start Call/Join` button. Calling `8:echo123` connects you with an echo bot, this feature is great for getting started and verifying your audio devices are working.
351401

@@ -572,7 +622,7 @@ Add the implementation to the `CallButton_Click` to start various kinds of calls
572622
{
573623
var callString = CalleeTextBox.Text.Trim();
574624

575-
call = await StartAcsCallAsync(callString);
625+
call = await StartCallAsync(callString);
576626
if (call != null)
577627
{
578628
call.StateChanged += OnStateChangedAsync;
@@ -657,7 +707,7 @@ In the meeting join scenario, `JoinCallOptions` is made available to customize t
657707
Once a `StartCallOptions` object is obtained, `CallAgent` can be used to initiate the Azure Communication Services call:
658708

659709
```C#
660-
private async Task<CommunicationCall> StartAcsCallAsync(string acsCallee)
710+
private async Task<CommunicationCall> StartCallAsync(string acsCallee)
661711
{
662712
var options = new StartCallOptions();
663713
var call = await this.callAgent.StartCallAsync( new [] { new UserCallIdentifier(acsCallee) }, options);
-4.44 KB
Loading
8.78 KB
Loading
-1.87 KB
Loading
12.8 KB
Loading

0 commit comments

Comments
 (0)