Skip to content

Commit d184694

Browse files
authored
Update control-mid-call-media-actions.md
add java, js and python snippets
1 parent 1645c79 commit d184694

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

articles/communication-services/how-tos/call-automation/control-mid-call-media-actions.md

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ var sendDtmfAsyncResult = await callAutomationClient.GetCallConnection(c
7070
### [Java](#tab/java)
7171
```java
7272
List<DtmfTone> tones = Arrays.asList(DtmfTone.ONE, DtmfTone.TWO, DtmfTone.THREE, DtmfTone.POUND);
73+
SendDtmfTonesOptions options =new SendDtmfTonesOptions(tones, new PhoneNumberIdentifier(c2Target));
74+
options.setOperationContext("dtmfs-to-ivr");
7375
callAutomationClient.getCallConnectionAsync(callConnectionId)
74-
.getCallMediaAsync()
75-
.sendDtmfTonesWithResponse(tones, new PhoneNumberIdentifier(c2Target), "dtmfs-to-ivr")
76-
.block();
76+
.getCallMediaAsync()
77+
.sendDtmfTonesWithResponse(options)
78+
.block();
7779
```
7880
### [JavaScript](#tab/javascript)
7981
```javascript
@@ -171,10 +173,12 @@ await callAutomationClient.GetCallConnection(callConnectionId)
171173
```
172174
### [Java](#tab/java)
173175
```java
176+
ContinuousDtmfRecognitionOptions options =new ContinuousDtmfRecognitionOptions(new PhoneNumberIdentifier(c2Target));
177+
options.setOperationContext("dtmf-reco-on-c2");
174178
callAutomationClient.getCallConnectionAsync(callConnectionId)
175-
.getCallMediaAsync()
176-
.startContinuousDtmfRecognitionWithResponse(new PhoneNumberIdentifier(c2Target), "dtmf-reco-on-c2")
177-
.block();
179+
.getCallMediaAsync()
180+
.startContinuousDtmfRecognitionWithResponse(options)
181+
.block();
178182
```
179183
### [JavaScript](#tab/javascript)
180184
```javascript
@@ -212,17 +216,17 @@ var continuousDtmfRecognitionOptions = new ContinuousDtmfRecognitionOpti
212216
};
213217

214218
var startContinuousDtmfRecognitionAsyncResult =awaitcallAutomationClient.GetCallConnection(callConnectionId)
215-
216219
    .GetCallMedia()
217-
218220
    .StartContinuousDtmfRecognitionAsync(continuousDtmfRecognitionOptions);
219221
```
220222
### [Java](#tab/java)
221223
```java
224+
ContinuousDtmfRecognitionOptions options =new ContinuousDtmfRecognitionOptions(new PhoneNumberIdentifier(c2Target));
225+
options.setOperationContext("dtmf-reco-on-c2");
222226
callAutomationClient.getCallConnectionAsync(callConnectionId)
223-
.getCallMediaAsync()
224-
.stopContinuousDtmfRecognitionWithResponse(new PhoneNumberIdentifier(c2Target), "dtmf-reco-on-c2")
225-
.block();
227+
.getCallMediaAsync()
228+
.stopContinuousDtmfRecognitionWithResponse(options)
229+
.block();
226230
```
227231
### [JavaScript](#tab/javascript)
228232
```javascript
@@ -260,30 +264,29 @@ if (acsEvent is ContinuousDtmfRecognitionToneReceived continuousDtmfReco
260264
```
261265
### [Java](#tab/java)
262266
``` java
263-
if (acsEvent instanceof ContinuousDtmfRecognitionToneReceived) {
264-
ContinuousDtmfRecognitionToneReceived event = (ContinuousDtmfRecognitionToneReceived) acsEvent;
265-
log.info("Tone detected: sequenceId=" + event.getToneInfo().getSequenceId()
266-
+ ", tone=" + event.getToneInfo().getTone().convertToString()
267-
+ ", context=" + event.getOperationContext());
267+
if (acsEventinstanceof ContinuousDtmfRecognitionToneReceived) {
268+
ContinuousDtmfRecognitionToneReceived event = (ContinuousDtmfRecognitionToneReceived) acsEvent;
269+
log.info("Tone detected: sequenceId=" + event.getSequenceId()
270+
+", tone=" + event.getTone().convertToString()
271+
+", context=" + event.getOperationContext());
268272
}
269273
```
270274
### [JavaScript](#tab/javascript)
271275
```javascript
272-
if (event.type === "Microsoft.Communication.ContinuousDtmfRecognitionToneReceived") {
273-
console.log("Tone detected: sequenceId=%s, tone=%s, context=%s",
274-
eventData.toneInfo.sequenceId,
275-
eventData.toneInfo.tone,
276-
eventData.operationContext);
277-
278-
}
276+
if (event.type === "Microsoft.Communication.ContinuousDtmfRecognitionToneReceived") {
277+
console.log("Tone detected: sequenceId=%s, tone=%s, context=%s",
278+
        eventData.sequenceId,
279+
        eventData.tone,
280+
eventData.operationContext);
281+
}
279282
```
280283
### [Python](#tab/python)
281284
```python
282-
if event.type == "Microsoft.Communication.ContinuousDtmfRecognitionToneReceived":
283-
app.logger.info("Tone detected: sequenceId=%s, tone=%s, context=%s",
284-
event.data['toneInfo']['sequenceId'],
285-
event.data['toneInfo']['tone'],
286-
event.data['operationContext'])
285+
if event.type == "Microsoft.Communication.ContinuousDtmfRecognitionToneReceived":
286+
app.logger.info("Tone detected: sequenceId=%s, tone=%s, context=%s",
287+
event.data['sequenceId'],
288+
                event.data['tone'],
289+
event.data['operationContext'])
287290
```
288291
-----
289292

0 commit comments

Comments
 (0)