Skip to content

Commit a784fd9

Browse files
authored
Update play-audio-how-to-js.md
add support for play barge-in
1 parent 1ee48df commit a784fd9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

articles/communication-services/how-tos/call-automation/includes/play-audio-how-to-js.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,45 @@ await callAutomationClient.getCallConnection(callConnectionId)
124124
.playToAll([ playSource ]);
125125
```
126126

127+
### Support for barge-in
128+
During scenarios where you're playing audio on loop to all participants e.g. waiting lobby you maybe playing audio to the participants in the lobby and keep them updated on their number in the queue. When you use the barge-in support, this will cancel the on-going audio and play your new message. Then if you wanted to continue playing your original audio you would make another play request.
129+
130+
```javascript
131+
// Interrupt media with text source
132+
//Option1:
133+
134+
const playSource: TextSource = { text: "Interrupt prompt", voiceName: "en-US-NancyNeural", kind: "textSource" };
135+
136+
const interruptOption: PlayToAllOptions = {
137+
loop: false,
138+
interruptCallMediaOperation: true,
139+
operationContext: "interruptOperationContext",
140+
operationCallbackUrl: process.env.CALLBACK_URI + "/api/callbacks"
141+
};
142+
143+
await callConnectionMedia.playToAll([playSource], interruptOption);
144+
145+
/*
146+
// Interrupt media with file source
147+
148+
Option2:
149+
150+
const playSource: FileSource = {
151+
url: MEDIA_URI + "MainMenu.wav",
152+
kind: "fileSource"
153+
};
154+
155+
const interruptOption: PlayToAllOptions = {
156+
loop: false,
157+
interruptCallMediaOperation: true,
158+
operationContext: "interruptOperationContext",
159+
operationCallbackUrl: process.env.CALLBACK_URI + "/api/callbacks"
160+
};
161+
162+
await callConnectionMedia.playToAll([playSource], interruptOption);
163+
*/
164+
```
165+
127166
## Play audio - Specific participant
128167

129168
In this scenario, audio is played to a specific participant.

0 commit comments

Comments
 (0)