Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PlayAudio Api on ConversationClient (Out-Call Scenario) #21430

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,68 @@ public virtual Response<GetCallRecordingStateResponse> GetRecordingState(string
}
}

/// <summary> Play Audio. </summary>
/// <param name="conversationId"> The conversation id. </param>
/// <param name="audioFileUri"> The uri of the audio file. </param>
/// <param name="operationContext">The operation context. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual async Task<Response<PlayAudioResponse>> PlayAudioAsync(string conversationId, Uri audioFileUri, string operationContext, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(PlayAudioAsync)}");
scope.Start();
try
{
Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
Argument.AssertNotNull(audioFileUri, nameof(audioFileUri));

// Currently looping media is not supported for out-call scenarios, thus setting it to false.
PlayAudioRequest request = new PlayAudioRequest()
{
AudioFileUri = audioFileUri.AbsoluteUri,
Loop = false,
Paresh-Arvind-Patil marked this conversation as resolved.
Show resolved Hide resolved
OperationContext = operationContext
};

return await RestClient.PlayAudioAsync(conversationId, request, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
scope.Failed(ex);
throw;
}
}

/// <summary> Play Audio. </summary>
/// <param name="conversationId"> The conversation id. </param>
/// <param name="audioFileUri"> The uri of the audio file. </param>
/// <param name="operationContext">The operation context. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
public virtual Response<PlayAudioResponse> PlayAudio(string conversationId, Uri audioFileUri, string operationContext, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(PlayAudio)}");
scope.Start();
try
{
Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId));
Argument.AssertNotNull(audioFileUri, nameof(audioFileUri));

// Currently looping media is not supported for out-call scenarios, thus setting it to false.
PlayAudioRequest request = new PlayAudioRequest()
{
AudioFileUri = audioFileUri.AbsoluteUri,
Loop = false,
Paresh-Arvind-Patil marked this conversation as resolved.
Show resolved Hide resolved
OperationContext = operationContext
};

return RestClient.PlayAudio(conversationId, request, cancellationToken);
}
catch (Exception ex)
{
scope.Failed(ex);
throw;
}
}

/// <summary>
/// Add participant
/// </summary>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,72 @@
}
}
},
"/calling/conversations/{conversationId}/PlayAudio": {
"post": {
"tags": [
"Call"
],
"summary": "Play audio in a call.",
"description": "Play audio in a call.",
"operationId": "Conversation_PlayAudio",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "conversationId",
"in": "path",
"description": "The conversation id which can be guid or encoded cs url",
"required": true,
"type": "string"
},
{
"name": "request",
"in": "body",
"description": "Play audio request.",
"required": true,
"schema": {
"$ref": "#/definitions/PlayAudioRequest"
}
},
{
"$ref": "#/parameters/ApiVersionParameter"
}
],
"responses": {
"202": {
"description": "Returns the play audio response.",
"schema": {
"$ref": "#/definitions/PlayAudioResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/CommunicationError"
},
"x-ms-error-response": true
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/CommunicationError"
},
"x-ms-error-response": true
},
"500": {
"description": "Internal server error.",
"schema": {
"$ref": "#/definitions/CommunicationError"
},
"x-ms-error-response": true
}
}
}
},
"/calling/conversations/{conversationId}/participants": {
"post": {
"tags": [
Expand Down Expand Up @@ -1033,6 +1099,10 @@
"audioFileId": {
"description": "An id for the media in the AudioFileUri, using which we cache the media resource.",
"type": "string"
},
"callbackUri": {
"description": "The callback Uri to receive PlayAudio status notifications.",
"type": "string"
}
}
},
Expand Down
Loading